Author vstinner
Recipients inada.naoki, rhettinger, serhiy.storchaka, vstinner
Date 2016-12-14.09:08:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1481706498.55.0.609128417985.issue28959@psf.upfronthosting.co.za>
In-reply-to
Content
> dict doesn't end with array.

Right, but...

Recently I looked at dict internals. As a newcomer, I have to confess that it's currently really hard to understand the purpose of each dict field: they are many "sizes": size of the hash table, number of usable entries, number of used entries, number of items in the dictionary, etc.

I like the idea of using the standard ob_size field (PyVarObject) to make it more explicitl that this field is the expected result of len(obj).

Technically, I don't know any function inside Python core which rely on the fact that object data is at the end of the main memory block.

Other builtin Python types:

* tuple: PyVarObject
* list: PyVarObject
* bytes: PyVarObject
* bytearray: PyVarObject
* memoryview: PyVarObject
* set: "used" field
* str: "length" field

The str type is super optimized for memory footprint, there are technical reasons for not used PyVarObject here, like backward compatibility.

It may make sense to modify PySetObject to use PyVarObject as well, but that's a different topic :-)
History
Date User Action Args
2016-12-14 09:08:18vstinnersetrecipients: + vstinner, rhettinger, inada.naoki, serhiy.storchaka
2016-12-14 09:08:18vstinnersetmessageid: <1481706498.55.0.609128417985.issue28959@psf.upfronthosting.co.za>
2016-12-14 09:08:18vstinnerlinkissue28959 messages
2016-12-14 09:08:17vstinnercreate