19.07.20 20:02, Guido van Rossum пише:
That looks expensive, esp. for objects implemented in Python — an extra dict entry plus a new unique int object. What is the problem you are trying to solve for these objects specifically? Just that the hex numbers look distracting doesn’t strike me as sufficient motivation.

It is the main problem that I want to solve. " at 0x7ff4c26b3eb0" is 18 characters long, and first and last digits usually are the same for different objects.

Also, since objects can reuse memory after destroying other objects, unique identifier can help to analyze logs.

It is not so expensive. New dict entry does not cost anything if the object already has a dict (space for 5 entries is reserved from the start). The size of small integer up to 2**30 is 28 bytes, and integers up to 255 does not cost anything. It is minor in comparison with the Python object size (48 bytes), dict size (104 bytes), and the size of other object attributes (locks, counters, etc). It is very unlikely the program will have millions of semaphores or event objects at one time, it is most likely it will use tens of them.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@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/P2KSIMU3FHWBCHVPRLF2QBLLWYZM6ILA/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to