-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-126868: Add freelist for compact int objects #126865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
0713034
be58ade
3f50b54
fa97302
d72486f
e07c218
328e0c1
e1dc2b3
9df776b
6b73046
db8247e
d1e4aa2
644e85a
9f86b6e
88274d6
1e548bd
13bc3e9
60220c0
593d621
efde111
928e912
437c24c
b034948
19f64f6
14681c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,7 +43,7 @@ static inline void | |
| _Py_DECREF_INT(PyLongObject *op) | ||
| { | ||
| assert(PyLong_CheckExact(op)); | ||
| _Py_DECREF_SPECIALIZED((PyObject *)op, (destructor)PyObject_Free); // needs to be converted to freelist? | ||
| _Py_DECREF_SPECIALIZED((PyObject *)op, (destructor) _PyLong_ExactDealloc); | ||
| } | ||
|
|
||
| static inline int | ||
|
|
@@ -222,7 +222,9 @@ _PyLong_FromMedium(sdigit x) | |
| assert(!IS_SMALL_INT(x)); | ||
| assert(is_medium_int(x)); | ||
|
|
||
| PyLongObject *v = _Py_FREELIST_POP(PyLongObject, ints); | ||
| // The small int cache is incompatible with _Py_NewReference which is called | ||
| // by _Py_FREELIST_POP. | ||
| PyLongObject *v = (PyLongObject *)_Py_FREELIST_POP_MEM(ints); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you go back to PyLongObject *v = (PyLongObject *)_Py_FREELIST_POP(ints);
if (v == NULL) {
v = PyObject_Malloc(sizeof(PyLongObject));
if (v == NULL) {
PyErr_NoMemory();
return NULL;
}
_PyObject_Init((PyObject*)v, &PyLong_Type);
}
digit abs_x = x < 0 ? -x : x;
_PyLong_SetSignAndDigitCount(v, x<0?-1:1, 1);
v->long_value.ob_digit[0] = abs_x;
return (PyObject*)v; |
||
| if (v == NULL) { | ||
| v = PyObject_Malloc(sizeof(PyLongObject)); | ||
| if (v == NULL) { | ||
|
|
@@ -3618,13 +3620,13 @@ long_richcompare(PyObject *self, PyObject *other, int op) | |
| void | ||
| _PyLong_ExactDealloc(PyObject *self) | ||
| { | ||
| assert(PyLong_CheckExact(self)); | ||
|
|
||
| if (_PyLong_IsCompact((PyLongObject *)self)) { | ||
| _Py_FREELIST_FREE(ints, self, PyObject_Free); | ||
| return; | ||
| if (PyLong_CheckExact(self)) { | ||
| if (_PyLong_IsCompact((PyLongObject *)self)) { | ||
| _Py_FREELIST_FREE(ints, self, PyObject_Free); | ||
| return; | ||
| } | ||
| } | ||
| PyObject_Free(self); | ||
| Py_TYPE(self)->tp_free(self); | ||
| } | ||
|
|
||
| static void | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also not sure whether you need the cast. If you need the cast, I'd suggest changing the signature of the drstructor itself.