File tree 5 files changed +10
-21
lines changed
5 files changed +10
-21
lines changed Original file line number Diff line number Diff line change @@ -335,7 +335,7 @@ struct _is {
335
335
The integers that are preallocated are those in the range
336
336
-_PY_NSMALLNEGINTS (inclusive) to _PY_NSMALLPOSINTS (not inclusive).
337
337
*/
338
- PyLongObject * small_ints [_PY_NSMALLNEGINTS + _PY_NSMALLPOSINTS ];
338
+ PyLongObject small_ints [_PY_NSMALLNEGINTS + _PY_NSMALLPOSINTS ];
339
339
struct _Py_bytes_state bytes ;
340
340
struct _Py_unicode_state unicode ;
341
341
struct _Py_float_state float_state ;
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ static inline PyObject* __PyLong_GetSmallInt_internal(int value)
17
17
PyInterpreterState * interp = _PyInterpreterState_GET ();
18
18
assert (- _PY_NSMALLNEGINTS <= value && value < _PY_NSMALLPOSINTS );
19
19
size_t index = _PY_NSMALLNEGINTS + value ;
20
- PyObject * obj = (PyObject * )interp -> small_ints [index ];
20
+ PyObject * obj = (PyObject * )& interp -> small_ints [index ];
21
21
// _PyLong_GetZero(), _PyLong_GetOne() and get_small_int() must not be
22
22
// called before _PyLong_Init() nor after _PyLong_Fini().
23
23
assert (obj != NULL );
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ extern PyStatus _PyUnicode_Init(PyInterpreterState *interp);
53
53
extern PyStatus _PyUnicode_InitTypes (void );
54
54
extern PyStatus _PyBytes_Init (PyInterpreterState * interp );
55
55
extern int _PyStructSequence_Init (void );
56
- extern int _PyLong_Init (PyInterpreterState * interp );
56
+ extern void _PyLong_Init (PyInterpreterState * interp );
57
57
extern int _PyLong_InitTypes (void );
58
58
extern PyStatus _PyTuple_Init (PyInterpreterState * interp );
59
59
extern PyStatus _PyFaulthandler_Init (int enable );
Original file line number Diff line number Diff line change @@ -5827,24 +5827,17 @@ PyLong_GetInfo(void)
5827
5827
return int_info ;
5828
5828
}
5829
5829
5830
- int
5830
+ void
5831
5831
_PyLong_Init (PyInterpreterState * interp )
5832
5832
{
5833
5833
for (Py_ssize_t i = 0 ; i < NSMALLNEGINTS + NSMALLPOSINTS ; i ++ ) {
5834
5834
sdigit ival = (sdigit )i - NSMALLNEGINTS ;
5835
5835
int size = (ival < 0 ) ? -1 : ((ival == 0 ) ? 0 : 1 );
5836
-
5837
- PyLongObject * v = _PyLong_New (1 );
5838
- if (!v ) {
5839
- return -1 ;
5840
- }
5841
-
5842
- Py_SET_SIZE (v , size );
5843
- v -> ob_digit [0 ] = (digit )abs (ival );
5844
-
5845
- interp -> small_ints [i ] = v ;
5836
+ interp -> small_ints [i ].ob_base .ob_base .ob_refcnt = 1 ;
5837
+ interp -> small_ints [i ].ob_base .ob_base .ob_type = & PyLong_Type ;
5838
+ interp -> small_ints [i ].ob_base .ob_size = size ;
5839
+ interp -> small_ints [i ].ob_digit [0 ] = (digit )abs (ival );
5846
5840
}
5847
- return 0 ;
5848
5841
}
5849
5842
5850
5843
@@ -5863,7 +5856,5 @@ _PyLong_InitTypes(void)
5863
5856
void
5864
5857
_PyLong_Fini (PyInterpreterState * interp )
5865
5858
{
5866
- for (Py_ssize_t i = 0 ; i < NSMALLNEGINTS + NSMALLPOSINTS ; i ++ ) {
5867
- Py_CLEAR (interp -> small_ints [i ]);
5868
- }
5859
+ (void )interp ;
5869
5860
}
Original file line number Diff line number Diff line change @@ -659,9 +659,7 @@ pycore_init_singletons(PyInterpreterState *interp)
659
659
{
660
660
PyStatus status ;
661
661
662
- if (_PyLong_Init (interp ) < 0 ) {
663
- return _PyStatus_ERR ("can't init longs" );
664
- }
662
+ _PyLong_Init (interp );
665
663
666
664
if (_Py_IsMainInterpreter (interp )) {
667
665
_PyFloat_Init ();
You can’t perform that action at this time.
0 commit comments