| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8598422 commit 9385266
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -499,6 +499,23 @@ Floating Point Objects | |||
| 499 | 499 | without error checking. | |
| 500 | 500 | ||
| 501 | 501 | ||
| 502 | + .. cfunction:: PyObject* PyFloat_GetInfo(void) | ||
| 503 | + | ||
| 504 | + Return a :ctype:`PyDictObject` object which contains information about the | ||
| 505 | + precision, minimum and maximum values of a float. It's a thin wrapper | ||
| 506 | + around the header file :file:`float.h`. | ||
| 507 | + | ||
| 508 | + | ||
| 509 | + .. cfunction:: double PyFloat_GetMax(void) | ||
| 510 | + | ||
| 511 | + Return the maximum representable finite float *DBL_MAX* as C :ctype:`double`. | ||
| 512 | + | ||
| 513 | + | ||
| 514 | + .. cfunction:: double PyFloat_GetMin(void) | ||
| 515 | + | ||
| 516 | + Return the minimum normalized positive float *DBL_MIN* as C :ctype:`double`. | ||
| 517 | + | ||
| 518 | + | ||
| 502 | 519 | .. _complexobjects: | |
| 503 | 520 | ||
| 504 | 521 | Complex Number Objects | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -422,13 +422,17 @@ by file descriptors. | |||
| 422 | 422 | Change the mode of the file given by *fd* to the numeric *mode*. See the docs | |
| 423 | 423 | for :func:`chmod` for possible values of *mode*. Availability: Unix. | |
| 424 | 424 | ||
| 425 | + .. versionadded:: 2.6 | ||
| 426 | + | ||
| 425 | 427 | ||
| 426 | 428 | .. function:: fchown(fd, uid, gid) | |
| 427 | 429 | ||
| 428 | 430 | Change the owner and group id of the file given by *fd* to the numeric *uid* | |
| 429 | 431 | and *gid*. To leave one of the ids unchanged, set it to -1. | |
| 430 | 432 | Availability: Unix. | |
| 431 | 433 | ||
| 434 | + .. versionadded:: 2.6 | ||
| 435 | + | ||
| 432 | 436 | ||
| 433 | 437 | .. function:: fdatasync(fd) | |
| 434 | 438 | ||
@@ -488,13 +492,6 @@ by file descriptors. | |||
| 488 | 492 | tty(-like) device, else ``False``. Availability: Macintosh, Unix. | |
| 489 | 493 | ||
| 490 | 494 | ||
| 491 | - .. function:: lchmod(path, mode) | ||
| 492 | - | ||
| 493 | - Change the mode of *path* to the numeric *mode*. If path is a symlink, this | ||
| 494 | - affects the symlink rather than the target. See the docs for :func:`chmod` | ||
| 495 | - for possible values of *mode*. Availability: Unix. | ||
| 496 | - | ||
| 497 | - | ||
| 498 | 495 | .. function:: lseek(fd, pos, how) | |
| 499 | 496 | ||
| 500 | 497 | Set the current position of file descriptor *fd* to position *pos*, modified by | |
@@ -800,6 +797,15 @@ Files and Directories | |||
| 800 | 797 | follow symbolic links. Availability: Unix. | |
| 801 | 798 | ||
| 802 | 799 | ||
| 800 | + .. function:: lchmod(path, mode) | ||
| 801 | + | ||
| 802 | + Change the mode of *path* to the numeric *mode*. If path is a symlink, this | ||
| 803 | + affects the symlink rather than the target. See the docs for :func:`chmod` | ||
| 804 | + for possible values of *mode*. Availability: Unix. | ||
| 805 | + | ||
| 806 | + .. versionadded:: 2.6 | ||
| 807 | + | ||
| 808 | + | ||
| 803 | 809 | .. function:: lchown(path, uid, gid) | |
| 804 | 810 | ||
| 805 | 811 | Change the owner and group id of *path* to the numeric *uid* and gid. This | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -184,6 +184,48 @@ always available. | |||
| 184 | 184 | error occurs. | |
| 185 | 185 | ||
| 186 | 186 | ||
| 187 | + .. data:: float_info | ||
| 188 | + | ||
| 189 | + A dict holding information about the float type. It contains low level | ||
| 190 | + information about the precision and internal representation. Please study | ||
| 191 | + your system's :file:`float.h` for more information. | ||
| 192 | + | ||
| 193 | + +---------------------+--------------------------------------------------+ | ||
| 194 | + | key | explanation | | ||
| 195 | + +=====================+==================================================+ | ||
| 196 | + | :const:`epsilon` | Difference between 1 and the next representable | | ||
| 197 | + | | floating point number | | ||
| 198 | + +---------------------+--------------------------------------------------+ | ||
| 199 | + | :const:`dig` | digits (see :file:`float.h`) | | ||
| 200 | + +---------------------+--------------------------------------------------+ | ||
| 201 | + | :const:`mant_dig` | mantissa digits (see :file:`float.h`) | | ||
| 202 | + +---------------------+--------------------------------------------------+ | ||
| 203 | + | :const:`max` | maximum representable finite float | | ||
| 204 | + +---------------------+--------------------------------------------------+ | ||
| 205 | + | :const:`max_exp` | maximum int e such that radix**(e-1) is in the | | ||
| 206 | + | | range of finite representable floats | | ||
| 207 | + +---------------------+--------------------------------------------------+ | ||
| 208 | + | :const:`max_10_exp` | maximum int e such that 10**e is in the | | ||
| 209 | + | | range of finite representable floats | | ||
| 210 | + +---------------------+--------------------------------------------------+ | ||
| 211 | + | :const:`min` | Minimum positive normalizer float | | ||
| 212 | + +---------------------+--------------------------------------------------+ | ||
| 213 | + | :const:`min_exp` | minimum int e such that radix**(e-1) is a | | ||
| 214 | + | | normalized float | | ||
| 215 | + +---------------------+--------------------------------------------------+ | ||
| 216 | + | :const:`min_10_exp` | minimum int e such that 10**e is a normalized | | ||
| 217 | + | | float | | ||
| 218 | + +---------------------+--------------------------------------------------+ | ||
| 219 | + | :const:`radix` | radix of exponent | | ||
| 220 | + +---------------------+--------------------------------------------------+ | ||
| 221 | + | :const:`rounds` | addition rounds (see :file:`float.h`) | | ||
| 222 | + +---------------------+--------------------------------------------------+ | ||
| 223 | + | ||
| 224 | + .. note:: | ||
| 225 | + | ||
| 226 | + The information in the table is simplified. | ||
| 227 | + | ||
| 228 | + | ||
| 187 | 229 | .. function:: getcheckinterval() | |
| 188 | 230 | ||
| 189 | 231 | Return the interpreter's "check interval"; see :func:`setcheckinterval`. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,6 +21,10 @@ PyAPI_DATA(PyTypeObject) PyFloat_Type; | |||
| 21 | 21 | #define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type) | |
| 22 | 22 | #define PyFloat_CheckExact(op) (Py_Type(op) == &PyFloat_Type) | |
| 23 | 23 | ||
| 24 | + PyAPI_FUNC(double) PyFloat_GetMax(void); | ||
| 25 | + PyAPI_FUNC(double) PyFloat_GetMin(void); | ||
| 26 | + PyAPI_FUNC(PyObject *) PyFloat_GetInfo(void); | ||
| 27 | + | ||
| 24 | 28 | /* Return Python float from string PyObject. */ | |
| 25 | 29 | PyAPI_FUNC(PyObject *) PyFloat_FromString(PyObject*); | |
| 26 | 30 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -699,10 +699,12 @@ def dash_R(the_module, test, indirect_test, huntrleaks): | |||
| 699 | 699 | fs = warnings.filters[:] | |
| 700 | 700 | ps = copy_reg.dispatch_table.copy() | |
| 701 | 701 | pic = sys.path_importer_cache.copy() | |
| 702 | - abcs = {obj: obj._abc_registry.copy() | ||
| 703 | - for abc in [getattr(_abcoll, a) for a in _abcoll.__all__ | ||
| 704 | - if issubclass(getattr(_abcoll, a), _Abstract)] | ||
| 705 | - for obj in abc.__subclasses__() + [abc]} | ||
| 702 | + abcs = {} | ||
| 703 | + for abc in [getattr(_abcoll, a) for a in _abcoll.__all__]: | ||
| 704 | + if not isinstance(abc, _Abstract): | ||
| 705 | + continue | ||
| 706 | + for obj in abc.__subclasses__() + [abc]: | ||
| 707 | + abcs[obj] = obj._abc_registry.copy() | ||
| 706 | 708 | ||
| 707 | 709 | if indirect_test: | |
| 708 | 710 | def run_the_test(): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -279,6 +279,8 @@ def test_attributes(self): | |||
| 279 | 279 | self.assert_(isinstance(sys.copyright, str)) | |
| 280 | 280 | self.assert_(isinstance(sys.exec_prefix, str)) | |
| 281 | 281 | self.assert_(isinstance(sys.executable, str)) | |
| 282 | + self.assert_(isinstance(sys.float_info, dict)) | ||
| 283 | + self.assertEqual(len(sys.float_info), 11) | ||
| 282 | 284 | self.assert_(isinstance(sys.hexversion, int)) | |
| 283 | 285 | self.assert_(isinstance(sys.maxint, int)) | |
| 284 | 286 | self.assert_(isinstance(sys.maxunicode, int)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,7 @@ | |||
| 9 | 9 | #include "formatter_unicode.h" | |
| 10 | 10 | ||
| 11 | 11 | #include <ctype.h> | |
| 12 | + #include <float.h> | ||
| 12 | 13 | ||
| 13 | 14 | #if !defined(__STDC__) | |
| 14 | 15 | extern double fmod(double, double); | |
@@ -48,6 +49,52 @@ fill_free_list(void) | |||
| 48 | 49 | return p + N_FLOATOBJECTS - 1; | |
| 49 | 50 | } | |
| 50 | 51 | ||
| 52 | + double | ||
| 53 | + PyFloat_GetMax(void) | ||
| 54 | + { | ||
| 55 | + return DBL_MAX; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + double | ||
| 59 | + PyFloat_GetMin(void) | ||
| 60 | + { | ||
| 61 | + return DBL_MIN; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + PyObject * | ||
| 65 | + PyFloat_GetInfo(void) | ||
| 66 | + { | ||
| 67 | + PyObject *d, *tmp; | ||
| 68 | + | ||
| 69 | + #define SET_FLOAT_CONST(d, key, const) \ | ||
| 70 | + tmp = PyFloat_FromDouble(const); \ | ||
| 71 | + if (tmp == NULL) return NULL; \ | ||
| 72 | + if (PyDict_SetItemString(d, key, tmp)) return NULL; \ | ||
| 73 | + Py_DECREF(tmp) | ||
| 74 | + #define SET_INT_CONST(d, key, const) \ | ||
| 75 | + tmp = PyInt_FromLong(const); \ | ||
| 76 | + if (tmp == NULL) return NULL; \ | ||
| 77 | + if (PyDict_SetItemString(d, key, tmp)) return NULL; \ | ||
| 78 | + Py_DECREF(tmp) | ||
| 79 | + | ||
| 80 | + d = PyDict_New(); | ||
| 81 | + | ||
| 82 | + SET_FLOAT_CONST(d, "max", DBL_MAX); | ||
| 83 | + SET_INT_CONST(d, "max_exp", DBL_MAX_EXP); | ||
| 84 | + SET_INT_CONST(d, "max_10_exp", DBL_MAX_10_EXP); | ||
| 85 | + SET_FLOAT_CONST(d, "min", DBL_MIN); | ||
| 86 | + SET_INT_CONST(d, "min_exp", DBL_MIN_EXP); | ||
| 87 | + SET_INT_CONST(d, "min_10_exp", DBL_MIN_10_EXP); | ||
| 88 | + SET_INT_CONST(d, "dig", DBL_DIG); | ||
| 89 | + SET_INT_CONST(d, "mant_dig", DBL_MANT_DIG); | ||
| 90 | + SET_FLOAT_CONST(d, "epsilon", DBL_EPSILON); | ||
| 91 | + SET_INT_CONST(d, "radix", FLT_RADIX); | ||
| 92 | + SET_INT_CONST(d, "rounds", FLT_ROUNDS); | ||
| 93 | + | ||
| 94 | + return d; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + | ||
| 51 | 98 | PyObject * | |
| 52 | 99 | PyFloat_FromDouble(double fval) | |
| 53 | 100 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,9 +23,11 @@ compiler specific". Therefore, these should be very rare. | |||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | 25 | NOTE: The following symbols are deprecated: | |
| 26 | - NT, WIN32, USE_DL_EXPORT, USE_DL_IMPORT, DL_EXPORT, DL_IMPORT | ||
| 26 | + NT, USE_DL_EXPORT, USE_DL_IMPORT, DL_EXPORT, DL_IMPORT | ||
| 27 | 27 | MS_CORE_DLL. | |
| 28 | 28 | ||
| 29 | + WIN32 is still required for the locale module. | ||
| 30 | + | ||
| 29 | 31 | */ | |
| 30 | 32 | ||
| 31 | 33 | #ifdef _WIN32_WCE | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,7 +44,7 @@ | |||
| 44 | 44 | Name="VCCLCompilerTool" | |
| 45 | 45 | AdditionalOptions="/Zm200 " | |
| 46 | 46 | AdditionalIncludeDirectories="..\Python;..\Modules\zlib" | |
| 47 | - PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED" | ||
| 47 | + PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;WIN32" | ||
| 48 | 48 | RuntimeLibrary="2" | |
| 49 | 49 | /> | |
| 50 | 50 | <Tool | |
@@ -119,7 +119,7 @@ | |||
| 119 | 119 | Name="VCCLCompilerTool" | |
| 120 | 120 | AdditionalOptions="/Zm200 " | |
| 121 | 121 | AdditionalIncludeDirectories="..\Python;..\Modules\zlib" | |
| 122 | - PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED" | ||
| 122 | + PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;WIN32" | ||
| 123 | 123 | RuntimeLibrary="2" | |
| 124 | 124 | /> | |
| 125 | 125 | <Tool | |
@@ -197,7 +197,7 @@ | |||
| 197 | 197 | InlineFunctionExpansion="0" | |
| 198 | 198 | EnableIntrinsicFunctions="false" | |
| 199 | 199 | AdditionalIncludeDirectories="..\Python;..\Modules\zlib" | |
| 200 | - PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED" | ||
| 200 | + PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;WIN32" | ||
| 201 | 201 | RuntimeLibrary="3" | |
| 202 | 202 | /> | |
| 203 | 203 | <Tool | |
@@ -275,7 +275,7 @@ | |||
| 275 | 275 | InlineFunctionExpansion="0" | |
| 276 | 276 | EnableIntrinsicFunctions="false" | |
| 277 | 277 | AdditionalIncludeDirectories="..\Python;..\Modules\zlib" | |
| 278 | - PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED" | ||
| 278 | + PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;WIN32" | ||
| 279 | 279 | RuntimeLibrary="3" | |
| 280 | 280 | /> | |
| 281 | 281 | <Tool | |
@@ -349,7 +349,7 @@ | |||
| 349 | 349 | Name="VCCLCompilerTool" | |
| 350 | 350 | AdditionalOptions="/Zm200 " | |
| 351 | 351 | AdditionalIncludeDirectories="..\Python;..\Modules\zlib" | |
| 352 | - PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED" | ||
| 352 | + PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;WIN32" | ||
| 353 | 353 | RuntimeLibrary="2" | |
| 354 | 354 | /> | |
| 355 | 355 | <Tool | |
@@ -424,7 +424,7 @@ | |||
| 424 | 424 | Name="VCCLCompilerTool" | |
| 425 | 425 | AdditionalOptions="/Zm200 " | |
| 426 | 426 | AdditionalIncludeDirectories="..\Python;..\Modules\zlib" | |
| 427 | - PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED" | ||
| 427 | + PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;WIN32" | ||
| 428 | 428 | RuntimeLibrary="2" | |
| 429 | 429 | /> | |
| 430 | 430 | <Tool | |
@@ -499,7 +499,7 @@ | |||
| 499 | 499 | Name="VCCLCompilerTool" | |
| 500 | 500 | AdditionalOptions="/Zm200 " | |
| 501 | 501 | AdditionalIncludeDirectories="..\Python;..\Modules\zlib" | |
| 502 | - PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED" | ||
| 502 | + PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;WIN32" | ||
| 503 | 503 | RuntimeLibrary="2" | |
| 504 | 504 | /> | |
| 505 | 505 | <Tool | |
@@ -574,7 +574,7 @@ | |||
| 574 | 574 | Name="VCCLCompilerTool" | |
| 575 | 575 | AdditionalOptions="/Zm200 " | |
| 576 | 576 | AdditionalIncludeDirectories="..\Python;..\Modules\zlib" | |
| 577 | - PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED" | ||
| 577 | + PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;WIN32" | ||
| 578 | 578 | RuntimeLibrary="2" | |
| 579 | 579 | /> | |
| 580 | 580 | <Tool | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1082,6 +1082,8 @@ _PySys_Init(void) | |||
| 1082 | 1082 | PyInt_FromLong(PyInt_GetMax())); | |
| 1083 | 1083 | SET_SYS_FROM_STRING("maxsize", | |
| 1084 | 1084 | PyInt_FromSsize_t(PY_SSIZE_T_MAX)); | |
| 1085 | + SET_SYS_FROM_STRING("float_info", | ||
| 1086 | + PyFloat_GetInfo()); | ||
| 1085 | 1087 | SET_SYS_FROM_STRING("maxunicode", | |
| 1086 | 1088 | PyInt_FromLong(PyUnicode_GetMax())); | |
| 1087 | 1089 | SET_SYS_FROM_STRING("builtin_module_names", | |
| Back | FazBrowse Home | New Git URL |
0 commit comments