Hi, has anyone considered mixing the "opaque handle" idea with tagged pointers?
I could imagine (on 64 bits) to reserve, say, a 'signed' 24 bits for a refcount and the rest for an index into an array of object/vtable pointer structs. All negative refcounts would have special meanings, such as
- this is the immortal None
- this is actually a tagged integer and not an object index
- this is a tagged float with an exact 32bit (or integer) value
- refcount has overflown and object has become immortal :)
Things like these, can't say which are reasonable and/or fast enough. I could also imagine reserving a few more bits for a builtin type ID to speed up type checks, especially for int/float/list/tuple/dict/fast-callable, maybe also things like flat tuples, where the items are directly stored consecutively in the object array following the tuple index.
Other runtimes could then implement the handles differently, as really opaque values and with or without tagged pointers, but CPython could use its own macros to give meaning to the tags. 32bit architectures would probably require different macros also for CPython, but since the whole design would need to work with and without tags, that should be doable.
Does this seem like something worth discussing?
Stefan