Skip to content

Can anyone explain the performance difference between scan_forward() and scan_reversed()? #1034

Answered by niklasf
jacksonthall22 asked this question in Q&A
Discussion options

You must be logged in to vote

It's really just the extra & and - on integers. Bitwise operations aren't as fast in Python as in other languages, and -bb is costly because it's not wrapping at 64 bits.

As an optimization, the library internals already use scan_reversed() where the iteration order is not observable.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jacksonthall22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants