-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-92914: Round the allocated size for lists up to the even number #92915
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
gh-92914: Round the allocated size for lists up to the even number #92915
Conversation
Objects/listobject.c
Outdated
@@ -94,6 +94,16 @@ list_preallocate_exact(PyListObject *self, Py_ssize_t size) | |||
assert(self->ob_item == NULL); | |||
assert(size > 0); | |||
|
|||
/* Since the Python memory allocator has granularity of 16 bytes, |
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.
alignment is 8bytes on 32bit platform.
Lines 878 to 884 in b86d783
#if SIZEOF_VOID_P > 4 | |
#define ALIGNMENT 16 /* must be 2^N */ | |
#define ALIGNMENT_SHIFT 4 | |
#else | |
#define ALIGNMENT 8 /* must be 2^N */ | |
#define ALIGNMENT_SHIFT 3 | |
#endif |
So I think we don't need the else {
block.
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
GH-92941 is a backport of this pull request to the 3.11 branch. |
…ber (pythonGH-92915) (cherry picked from commit 8a6af5a) Co-authored-by: Serhiy Storchaka <[email protected]>
GH-92942 is a backport of this pull request to the 3.10 branch. |
…ber (pythonGH-92915) (cherry picked from commit 8a6af5a) Co-authored-by: Serhiy Storchaka <[email protected]>
…H-92915) (GH-92942) (cherry picked from commit 8a6af5a) Co-authored-by: Serhiy Storchaka <[email protected]>
…H-92915) (cherry picked from commit 8a6af5a) Co-authored-by: Serhiy Storchaka <[email protected]>
Closes #92914.