On Sun, 19 Jul 2020 18:38:30 +0300 Serhiy Storchaka firstname.lastname@example.org wrote:
I have problem with the location of hexadecimal memory address in custom reprs.
<threading.BoundedSemaphore: 2/3 at 0x7ff4c26b3eb0>
<threading.BoundedSemaphore at 0x7ff4c26b3eb0: 2/3>
How about putting it in parentheses, to point more clearly that it can most of the time be ignored:
<threading.BoundedSemaphore: 2/3 (at 0x7ff4c26b3eb0)>
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?
I would like it if it applied to all objects, but doing it only for certain objects will be distracting and confusing (does the serial number point to a specific feature? it turns out it doesn't, it's just an arbitrary aesthetical choice).