10000 gh-72902: improve Fraction(str) speed (don't use regexp's) by skirpichev · Pull Request #133994 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-72902: improve Fraction(str) speed (don't use regexp's) #133994

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update Lib/fractions.py
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
  • Loading branch information
skirpichev and eendebakpt authored May 16, 2025
commit 7c567fcd6cbf4da33989f3318ba2f7b3b7cd234a
4 changes: 2 additions & 2 deletions Lib/fractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ def __new__(cls, numerator=0, denominator=None):
numerator = int(num)
elif num and not is_fraction_format:
denominator = 1
num, _, exp = num.replace('E', 'e').partition('e')
if _ and not exp:
num, is_exp_format, exp = num.replace('E', 'e').partition('e')
if is_exp_format and not exp:
raise ValueError
num, _, decimal = num.partition('.')
if num:
Expand Down
Loading
0