Hi Serhiy, Can I suggest using a short hash of the id as a prefix to the id?
I have problem with the location of hexadecimal memory address in custom reprs.
vs
The long hexadecimal number makes the repr longer and distracts attention from other useful information. We could get rid of it, but it is useful if we want to distinguish objects of the same type. Although it is hard to distinguish long hexadecimal numbers which differ only by few digits in the middle.
What if use serial numbers to differentiate instances?
where the serial number starts with 1 and increased for every new instance of that type.
The advantages are:
* Shorter repr. * Easier to distinguish different objects. * The serial number is unique for the life of program and cannot be reused (in contrary to id/memory address).
The disadvantages are:
* Increased object size and creation time.
I do not propose to use serial numbers for all objects, because it would increase the size of objects and the fixed-size integer can be overflowed for some short-living objects created in mass (like numbers, strings, tuples). But only for some custom objects implemented in Python, for which size and creation time are not critical. I want to start with synchronization objects in threading and multiprocessing which did not have custom reprs, than change reprs of locks and asyncio objects.
Is it worth to do? _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/E6YEXMQ4...
Code of Conduct: http://python.org/psf/codeofconduct/