homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author wbolster
Recipients wbolster
Date 2017年07月20日.17:15:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1500570928.48.0.991848922118.issue30977@psf.upfronthosting.co.za>
In-reply-to
Content
memory usage for uuid.UUID seems larger than it has to be. it seems that using __slots__ will save around ~100 bytes per instance, which is very significant, e.g. when dealing with large sets of uuids (which are often used as "primary keys" into external data stores).
uuid.UUID has a __setattr__ that prevents any extra attributes to be
set:
 def __setattr__(self, name, value):
 raise TypeError('UUID objects are immutable')
...so it seems to me not having __dict__ should not cause any problems?
before (RES column):
>>> import uuid
>>> y = {uuid.uuid4() for _ in range(1000000)}
 PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
23020 wbolster 20 0 315M 253M 7256 S 0.0 1.6 0:04.98 python
with slots:
>>> import uuid
>>> y = {uuid.uuid4() for _ in range(1000000)}
 PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
21722 wbolster 20 0 206M 145M 7348 S 0.0 0.9 0:05.03 python
i will open a pr on github shortly.
History
Date User Action Args
2017年07月20日 17:15:28wbolstersetrecipients: + wbolster
2017年07月20日 17:15:28wbolstersetmessageid: <1500570928.48.0.991848922118.issue30977@psf.upfronthosting.co.za>
2017年07月20日 17:15:28wbolsterlinkissue30977 messages
2017年07月20日 17:15:27wbolstercreate

AltStyle によって変換されたページ (->オリジナル) /