Skip to content
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

Optimize the Fraction class arithmetics for small components #91851

Closed
skirpichev opened this issue Apr 23, 2022 · 0 comments · Fixed by #25518
Closed

Optimize the Fraction class arithmetics for small components #91851

skirpichev opened this issue Apr 23, 2022 · 0 comments · Fixed by #25518
Labels
performance Performance or resource usage type-feature A feature request or enhancement

Comments

@skirpichev
Copy link
Member

skirpichev commented Apr 23, 2022

After #24779 there are some speed regressions, which can be solved by using private attributes in magic methods.

Also, right now the fractions module code is using sometimes private attributes (_numerator and _denominator, e.g. in the __int__) and sometimes - public (numerator and denominator, e.g. in the __floor__). This looks not very consistent, at least.

Linked PRs

@skirpichev skirpichev added the type-feature A feature request or enhancement label Apr 23, 2022
mdickinson pushed a commit that referenced this issue Jan 6, 2023
Make some trivial performance optimizations in Fraction

Uses private class attributes `_numerator` and `_denominator` in place of the `numerator` and `denominator` property accesses.

Co-authored-by: hauntsaninja <[email protected]>
@AlexWaygood AlexWaygood added the performance Performance or resource usage label Jan 6, 2023
hauntsaninja pushed a commit that referenced this issue Jan 8, 2023
Adapted from
046c84e8f9

This makes arithmetic between Fractions with small components
just as fast as before #24779, at some expense of
mixed arithmetic (e.g. Fraction + int).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance or resource usage type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants