[issue23103] ipaddress should be Flyweight
Serhiy Storchaka
report at bugs.python.org
Tue Dec 23 15:50:59 CET 2014
Serhiy Storchaka added the comment:
IP address instances already are immutable and flyweight. There are no mutating methods. And a number of address attributes (packed, is_loopback, etc) are calculated on fly from integer representation.
But IP address objects can be lighter.
1) Use __slots__.
2) Every instance has the _version attribute. Why this is not class attribute?
3) Memory consumption can be even less if IP addresses would int subclasses. But this changes the API (in particular adds the __index__ method) and I doubt that we should do this.
----------
nosy: +serhiy.storchaka
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23103>
_______________________________________
More information about the Python-bugs-list
mailing list