Replies: 4 comments 4 replies
-
What about putting the difference in I think that's how str objects work internally (https://docs.python.org/3.10/c-api/unicode.html#c.PyASCIIObject). |
Beta Was this translation helpful? Give feedback.
-
I would rather we just remove |
Beta Was this translation helpful? Give feedback.
-
Is this portable enough? It's my understanding that comparing pointers from different buffers is implementation-defined and can give unexpected results on segmented address spaces: mimalloc's mi_heap_check_owned() function is documented as
|
Beta Was this translation helpful? Give feedback.
-
I made a draft PR.
RAM used by tuple 706,096 bytes -> 393,712 (no GC header) + 211,792 (regular) bytes main branch
gc-less tuple
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
bytes, str, dict, and tuple are the four major memory eaters. I proposed three ideas to reduce bytes, str, dict memory usage:
Now I am considering how to reduce memory usage of tuples. As you know, many tuples are created during loading modules (co_consts, co_names, etc...), and most of them are untracked because all contents are immutables. So GC header wastes 16bytes on each tuples.
I looked
_PyObject_IS_GC()
and foundtp_is_gc
. I never know it!I have three ideas how to implement tp_is_gc of tuple.
Py_SIZE(tuple)
.PYTHONMALLOC=malloc valgrind ./python ...
would be difficult.Beta Was this translation helpful? Give feedback.
All reactions