You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a response to your blog post and modification to RanCat regarding a a supposed 100% performance improvement.
It's not acceptable to only consider the first 1000 elements of a file when selecting one at random when, more than likely, the dictionary will be presorted and have much more than 1000 elements.
I suggest you take the following approach:
Get the size of the file in bytes size = os.stat(filename).st_size
Open the file f= open(filename)
Jump to a random spot in said file f.seek(random.randint(0, size)
Move backward(or forward) until you hit a newline
Read the entire line word = f.readLine()
Close file f.close()
I wanted to see what you thought before putting together a PR.
The text was updated successfully, but these errors were encountered:
I think this definitely could be viable, I hadn't thought of it before. One thing to keep in mind when implementing this is that we need it to work when RanCat._unique = True
This is a response to your blog post and modification to RanCat regarding a a supposed 100% performance improvement.
It's not acceptable to only consider the first 1000 elements of a file when selecting one at random when, more than likely, the dictionary will be presorted and have much more than 1000 elements.
I suggest you take the following approach:
size = os.stat(filename).st_size
f= open(filename)
f.seek(random.randint(0, size)
word = f.readLine()
f.close()
I wanted to see what you thought before putting together a PR.
The text was updated successfully, but these errors were encountered: