On 19/07/2020 16:38, Serhiy Storchaka wrote:
I have problem with the location of hexadecimal memory address in custom reprs.
I agree they are "noise" mostly and difficult to distinguish when you need to.
What if use serial numbers to differentiate instances?
<threading.BoundedSemaphore #5: 2/3>
where the serial number starts with 1 and increased for every new instance of that type.
What would happen at a __class__ assignment?
IIUC class assignability is an equivalence relation amongst types: serial numbers would have to be unique within the equivalence class, not within the type. Otherwise, they would have to change (unlike id()), may not round-trip if __class__ were assigned there and back.