You mentioned that in the previous thread, but I don’t see how a reversible id() makes this possible. Can you show a worked example?
Different languages are different. Python’s object, memory, and variable model are different than C or Rust. JavaScript, Java, Ruby, etc don’t have pointers because they are more similar to Python.
Here are some things you have to consider about Python’s mechanisms:
(1) Object ids are not unique. The same id can refer to different objects at different times. Try running this:
def f():
x = [1]
return id(x)
def g():
y = [2, 3, 4, 5]
return id(y)
flistid = f()
glistid = g()
print(f"{flistid = }, {glistid = }")
I get: flistid = 4331774144, glistid = 4331774144. What should objects()[4331774144] return?
(2) In order to get an object back from an integer, you need an explicit mapping. You can’t simply examine memory at that address, you don’t know whether it’s a live object or not. As shown above, you don’t know if it it’s the same object as when you captured the id. How large will this mapping be?
(3) How would you use this int→object mapping? Wherever you are keeping the int, why not keep the object? The ints are objects in Python anyway, so you can keep the original object.
(4) If you do have a need for an int→object mapping, you can keep one yourself for the small set of objects you need in the mapping. WeakRefs might be useful.
I’m really pleased to see you excited enough about Python to suggest changes. I think as you dive more into the deeper logic of its behavior, you will discover much to marvel at.
BTW: when continuing this discussion, it’s really helpful to copy the portion of text you are replying to. Discord has Quote and Copy Quote features when you select text. It makes it easier to follow the discussion. It takes a little more time, but it’s worth it.
(sorry, edited a few times to get the code markup right!)