diff options
author | Victor Stinner <vstinner@python.org> | 2019-12-17 12:02:18 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-17 12:02:18 (GMT) |
commit | 630c8df5cf126594f8c1c4579c1888ca80a29d59 (patch) | |
tree | 7114d3190806b8b23b23211c0fdc8e0c507ff0c1 /Include/internal/pycore_pystate.h | |
parent | f501db2b93a9d3d840b6fb38d6bdda8bcc400d4a (diff) | |
download | cpython-630c8df5cf126594f8c1c4579c1888ca80a29d59.zip cpython-630c8df5cf126594f8c1c4579c1888ca80a29d59.tar.gz cpython-630c8df5cf126594f8c1c4579c1888ca80a29d59.tar.bz2 |
bpo-38858: Small integer per interpreter (GH-17315)
Each Python subinterpreter now has its own "small integer
singletons": numbers in [-5; 257] range.
It is no longer possible to change the number of small integers at
build time by overriding NSMALLNEGINTS and NSMALLPOSINTS macros:
macros should now be modified manually in pycore_pystate.h header
file.
For now, continue to share _PyLong_Zero and _PyLong_One singletons
between all subinterpreters.
Diffstat (limited to 'Include/internal/pycore_pystate.h')
-rw-r--r-- | Include/internal/pycore_pystate.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Include/internal/pycore_pystate.h b/Include/internal/pycore_pystate.h index aa2103f..b78ed69 100644 --- a/Include/internal/pycore_pystate.h +++ b/Include/internal/pycore_pystate.h @@ -56,6 +56,9 @@ struct _ceval_runtime_state { typedef PyObject* (*_PyFrameEvalFunction)(struct _frame *, int); +#define _PY_NSMALLPOSINTS 257 +#define _PY_NSMALLNEGINTS 5 + // The PyInterpreterState typedef is in Include/pystate.h. struct _is { @@ -139,6 +142,15 @@ struct _is { int atbol; } listnode; } parser; + +#if _PY_NSMALLNEGINTS + _PY_NSMALLPOSINTS > 0 + /* Small integers are preallocated in this array so that they + can be shared. + The integers that are preallocated are those in the range + -_PY_NSMALLNEGINTS (inclusive) to _PY_NSMALLPOSINTS (not inclusive). + */ + PyLongObject* small_ints[_PY_NSMALLNEGINTS + _PY_NSMALLPOSINTS]; +#endif }; PyAPI_FUNC(struct _is*) _PyInterpreterState_LookUpID(PY_INT64_T); |