Could you add a bit more detail on what this would look like, maybe even an example implementation?
I am pretty sure we wouldn’t want to add anything to PyObject literally: that would mean increased memory usage from every single Python object, which would be very costly. On the other hand, adding something just to the C struct for GenericAlias objects should be fine. And adding something to PyTypeObject might be OK, but we’ll have to consider it carefully.
I really do mean adding a field and a PyMemberDef to object, I’m not very familiar with C so any implementation I do come up with probably won’t work. Your concern is by far the largest one I would have adding this. If you have any idea though as to how adding a field to GenericAlias or PyTypeObject would mean that we could introspect the original list I’d be very happy to hear them.
My only other idea would be just adding it to things that support subscription to produce a GenericAlias automatically somehow but how that would work is completely beyond my knowledge and would be full of edge cases but that would certainly help to reduce the memory overhead.