Message298738
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. |
|
Date |
User |
Action |
Args |
2017-07-20 17:15:28 | wbolster | set | recipients:
+ wbolster |
2017-07-20 17:15:28 | wbolster | set | messageid: <1500570928.48.0.991848922118.issue30977@psf.upfronthosting.co.za> |
2017-07-20 17:15:28 | wbolster | link | issue30977 messages |
2017-07-20 17:15:27 | wbolster | create | |
|