-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fast xoring in python #686
Comments
Why? |
this is MUCH faster |
How much? |
Could you elaborate on this? Could you post benchmark results or insights why this works faster? |
depending on datasize, on my computer, from 1.1 to 31 times. The most "optimal" size for benchmarking is data size of 3 MB |
|
it is faster even on one-byte message :) |
Looks not oblivious why more operations(and code) is faster than shorter version:
Do you have an explanation for this? |
sure, original implementation is executed in python, while my implementation is executed in C. |
I don't care too much because cythonized version 7 times faster than your optimized python one. You may make a pull request though. |
@socketpair But enumeration and bytes operations are not made in Python, right? Math is the same. What I see in yours is more function/method calls which means more work to do. Still curious. |
@asvetlov about cython, what you compare with what ? |
@kxepal |
This is a rule: block operations are always faster than byte-by-byte. |
True, thanks! |
would this be merged so ? |
also, constructing big integer is cheap operation. xoring two bigintegers with same size is cheap too. The most time (as I think) this function spent in constructing mask...I tried 4 approaches, maybe you know faster one ? |
@socketpair I've compared your Sorry, I cannot merge still nonexistent pull request :) |
will make pull request. Also I have improved performance of cython-based implementation :) |
I have installed pytest from pip...
|
Please install pytest-raisesregexp manually. |
Fixed by 66c4234 |
Weboscket XOR performance improved. Fixes #686
oops :) race-condition :) :) I have some small improvements on that, but applied 15 second later then you merge PR |
Also, you have replaced
And also, you did not import |
Rebased and updated branch |
|
If your latest update are missed in master branch -- please create new PR. I wrote about |
I have check Python sources. endiannes in that function just change order in which bytes are read from bytearray, and nothing more. Since little-endiannes mean reading from begin to end, this is more optimal. Since no interpretation to actual number values is done (i.e. no reconversion), there will be no performance hurt, but instead, since memory read left to right, performance improvements will be acieved :) |
Memory is read by cache lines, not byte-by-byte. |
OK, agree, changes are not so significant |
Same issue: http://bugs.python.org/issue19251 |
FYI I wrote a patch for that python issue @socketpair linked to, to allow things like |
instead of
please use this:
The text was updated successfully, but these errors were encountered: