You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is dedicated code for formatting integer literals in f-strings, which avoids converting C integers to Python integer objects just for formatting them as strings. It is used by the FormattedValueNode in ExprNodes.py.
implement relevant tests in tests/run/fstring.pyx and/or check if tests/run/test_fstring.pyx (copied from CPython's test suite) covers this sufficiently
extract the relevant parts of CPython's formatting implementation (potentially limiting it to easy to support formats)
create a new C utility function in TypeConversion.c that formats double values
implement CFloatType.can_coerce_to_pystring() in PyrexTypes.py to make it return True when supported
implement CFloatType.convert_to_pystring() to call the formatting C function.
This can be done incrementally for selected formatting modifiers, e.g. a format like f"{x: .2f}" should be fairly easy to support and covers a large part of the usages.
Hint: this ticket requires good C skills.
The text was updated successfully, but these errors were encountered:
There is dedicated code for formatting integer literals in f-strings, which avoids converting C integers to Python integer objects just for formatting them as strings. It is used by the
FormattedValueNode
inExprNodes.py
.The same should be done for C float/double values, as Python provides PyOS_double_to_string(). See CPython's own float formatting in unicodeobject.c and formatter_unicode.c.
tests/run/fstring.pyx
and/or check iftests/run/test_fstring.pyx
(copied from CPython's test suite) covers this sufficientlyTypeConversion.c
that formats double valuesCFloatType.can_coerce_to_pystring()
inPyrexTypes.py
to make it returnTrue
when supportedCFloatType.convert_to_pystring()
to call the formatting C function.This can be done incrementally for selected formatting modifiers, e.g. a format like
f"{x: .2f}"
should be fairly easy to support and covers a large part of the usages.Hint: this ticket requires good C skills.
The text was updated successfully, but these errors were encountered: