I have problem with the location of hexadecimal memory address in custom
<threading.BoundedSemaphore: 2/3 at 0x7ff4c26b3eb0>
<threading.BoundedSemaphore at 0x7ff4c26b3eb0: 2/3>
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?
<threading.BoundedSemaphore #5: 2/3>
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
Is it worth to do?
Python-Dev mailing list -- firstname.lastname@example.org
To unsubscribe send an email to email@example.com
Message archived at https://firstname.lastname@example.org/message/E6YEXMQ4OE5YGZGRP62JOLTAGBCL6RCX/
Code of Conduct: http://python.org/psf/codeofconduct/