3 ms·
Does anyone know what the code is "compiled" into, if not a hash table?
by RaphiePS 13y ago
Does anyone know what the code is "compiled" into, if not a hash table?
- Mithaldu 13y agoI'm not entirely sure, but based on my experience with OO in Perl i guess that it simply uses an array in a special attribute, instead of putting the various attributes into dict keys on the actual object. Possibly it even uses some kind of inside-out implementation where the arrays are stored via closure in some other scope and only visible to accessor methods.
- makomk 13y agoI believe CPython just allocates slightly more memory than the structure describing the object requres and stores the attributes in fixed locations immediately after it. It's basically the same way that it handles attributes of built-in types, except that those also have a C struct describing the attribute layout.