Skip to content

Conversation

greglucas
Copy link
Collaborator

int.from_bytes() is about 2x slower than a direct bitshift of two values, and we avoid some other checks as well.

python -m timeit "b=b'\x01\x02\x03\x04\x05\x06'*100; int.from_bytes(b[-2:], 'big')" 
5000000 loops, best of 5: 80.2 nsec per loop

python -m timeit "b=b'\x01\x02\x03\x04\x05\x06'*100; (b[-2] << 8) | b[-1]"
5000000 loops, best of 5: 47.8 nsec per loop

int.from_bytes() is about 4x slower than a direct bitshift of two values.
@greglucas greglucas requested a review from medley56 as a code owner February 21, 2025 17:30
Copy link

codecov bot commented Feb 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.86%. Comparing base (5028734) to head (92da56a).
Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #150      +/-   ##
==========================================
- Coverage   91.86%   91.86%   -0.01%     
==========================================
  Files          36       36              
  Lines        2557     2556       -1     
==========================================
- Hits         2349     2348       -1     
  Misses        208      208              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@medley56 medley56 merged commit 58bd41b into lasp:main Feb 26, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants