3 ms·
The comparison is interesting, but CPython's lavish use of memory (which of course has a performance impact by clogging caches, though that's one of the least p
by dom0 9y ago
The comparison is interesting, but CPython's lavish use of memory (which of course has a performance impact by clogging caches, though that's one of the least problems you have with CPython, performance wise) is well known. ¹
This is in part because there are still macros such as PyBytes_GET_SIZE which directly access struct members, and these macros are part of the stable interpreter ABI. That doesn't mean small integer opts and such for length fields aren't possible, it just means they can't happen for Python 3 any more. Tagged pointer would probably break too much code to ever happen.
¹ well known as it may be, people are still surprised that bytes() requires at least 33 bytes (due to the implicit extra NUL byte), an empty string is around 50 bytes and every item in a dict or set takes between 30 and 70 bytes. All this overhead adds up.
--
Borg works around these problems with a simple hash table (straight out of the text book, with some associated issues). Even though that one is in itself inefficient in how it uses memory, it still only uses a fraction of what the equivalent dict in CPython 3.6 would use. I recently added a similar, pure Python construct in another place (borg mount).