Mercurial > cpython-lru_cache-weakref
comparison Python/sysmodule.c @ 53185:97ae7a709c1d
Issue #1580: use short float repr where possible.
- incorporate and adapt David Gay's dtoa and strtod
into the Python core
- on platforms where we can use Gay's code (almost
all!), repr(float) is based on the shortest
sequence of decimal digits that rounds correctly.
- add sys.float_repr_style attribute to indicate
whether we're using Gay's code or not
- add autoconf magic to detect and enable SSE2
instructions on x86/gcc
- slight change to repr and str: repr switches
to exponential notation at 1e16 instead of
1e17, str switches at 1e11 instead of 1e12
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Thu, 16 Apr 2009 19:52:09 +0000 |
| parents | bb5de24a343f |
| children | 1b15a57e1f02 |
comparison
equal
deleted
inserted
replaced
| 53178:975be1eb3ebf | 53185:97ae7a709c1d |
|---|---|
| 1023 copyright -- copyright notice pertaining to this interpreter\n\ | 1023 copyright -- copyright notice pertaining to this interpreter\n\ |
| 1024 platform -- platform identifier\n\ | 1024 platform -- platform identifier\n\ |
| 1025 executable -- pathname of this Python interpreter\n\ | 1025 executable -- pathname of this Python interpreter\n\ |
| 1026 prefix -- prefix used to find the Python library\n\ | 1026 prefix -- prefix used to find the Python library\n\ |
| 1027 exec_prefix -- prefix used to find the machine-specific Python library\n\ | 1027 exec_prefix -- prefix used to find the machine-specific Python library\n\ |
| 1028 float_repr_style -- string indicating the style of repr() output for floats\n\ | |
| 1028 " | 1029 " |
| 1029 ) | 1030 ) |
| 1030 #ifdef MS_WINDOWS | 1031 #ifdef MS_WINDOWS |
| 1031 /* concatenating string here */ | 1032 /* concatenating string here */ |
| 1032 PyDoc_STR( | 1033 PyDoc_STR( |
| 1425 PyStructSequence_InitType(&FlagsType, &flags_desc); | 1426 PyStructSequence_InitType(&FlagsType, &flags_desc); |
| 1426 SET_SYS_FROM_STRING("flags", make_flags()); | 1427 SET_SYS_FROM_STRING("flags", make_flags()); |
| 1427 /* prevent user from creating new instances */ | 1428 /* prevent user from creating new instances */ |
| 1428 FlagsType.tp_init = NULL; | 1429 FlagsType.tp_init = NULL; |
| 1429 FlagsType.tp_new = NULL; | 1430 FlagsType.tp_new = NULL; |
| 1431 | |
| 1432 /* float repr style: 0.03 (short) vs 0.029999999999999999 (legacy) */ | |
| 1433 #ifndef PY_NO_SHORT_FLOAT_REPR | |
| 1434 SET_SYS_FROM_STRING("float_repr_style", | |
| 1435 PyUnicode_FromString("short")); | |
| 1436 #else | |
| 1437 SET_SYS_FROM_STRING("float_repr_style", | |
| 1438 PyUnicode_FromString("legacy")); | |
| 1439 #endif | |
| 1430 | 1440 |
| 1431 #undef SET_SYS_FROM_STRING | 1441 #undef SET_SYS_FROM_STRING |
| 1432 if (PyErr_Occurred()) | 1442 if (PyErr_Occurred()) |
| 1433 return NULL; | 1443 return NULL; |
| 1434 return m; | 1444 return m; |
