[issue23103] Reduce memory usage for ipaddress object instances
Nick Coghlan added the comment: For the record, I don't think the weakref support is likely to be particularly useful either, and if we'd used __slots__ from the beginning, I expect we would have left it out. It's specifically the idea of *taking weakref support away* when weakrefs currently work that seems dubious to me. It may be worth asking the question on Python dev, as it's possible I'm being overly cautious, and it would be reasonable to drop the weakref support in 3.5.0, while mentioning in the 3.5 porting notes that we'd be open to the idea of adding weakref support back in a 3.5.x maintenance release if anyone reports its removal as a regression from 3.4. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23103 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23103] Reduce memory usage for ipaddress object instances
Antoine Pitrou added the comment: -1 on dropping weakref support. It's a feature, and it costs almost nothing. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23103 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23103] Reduce memory usage for ipaddress object instances
Serhiy Storchaka added the comment: Nick, what is your thoughts about the patch? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23103 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23103] Reduce memory usage for ipaddress object instances
Roundup Robot added the comment: New changeset 88a5c1698ca4 by Serhiy Storchaka in branch 'default': Issue #23103: Reduced the memory consumption of IPv4Address and IPv6Address. https://hg.python.org/cpython/rev/88a5c1698ca4 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23103 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23103] Reduce memory usage for ipaddress object instances
Nick Coghlan added the comment: +1 from me, although since we're committing to preserving the weakref support for compatibility reasons now, I'm wondering if we should also add a test for it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23103 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23103] Reduce memory usage for ipaddress object instances
Serhiy Storchaka added the comment: OK. But I hesitate that weakref support is useful for IP addresses. -- assignee: - serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23103 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23103] Reduce memory usage for ipaddress object instances
Changes by Serhiy Storchaka storch...@gmail.com: -- resolution: - fixed stage: patch review - resolved ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23103 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23103] Reduce memory usage for ipaddress object instances
Changes by Serhiy Storchaka storch...@gmail.com: -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23103 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23103] Reduce memory usage for ipaddress object instances
Serhiy Storchaka added the comment: Synchronized with tip. -- Added file: http://bugs.python.org/file38047/ipaddress_lightweight_4.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23103 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23103] Reduce memory usage for ipaddress object instances
Serhiy Storchaka added the comment: I believe you need to add a bunch of __slots__ = () to various base classes in the module, even though they lack member variables. Done. Here is updated patch. I don't think that IP addresses need weak references more than base types as integers or strings. Caching can be implemented without weak references (some caching already is used for networks), and I afraid that supporting weak references list will spent more memory than saved with caching. -- Added file: http://bugs.python.org/file37560/ipaddress_lightweight_2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23103 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23103] Reduce memory usage for ipaddress object instances
Antoine Pitrou added the comment: I don't think that IP addresses need weak references more than base types as integers or strings. People may already be taking weak references, so it's a matter of compatibility. (and weakrefs can actually help implement an interning scheme as proposed here) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23103 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23103] Reduce memory usage for ipaddress object instances
Serhiy Storchaka added the comment: Updated patch preserves weak references support. -- Added file: http://bugs.python.org/file37563/ipaddress_lightweight_3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23103 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23103] Reduce memory usage for ipaddress object instances
Serhiy Storchaka added the comment: As far as adding __slots__ breaks pickling with protocols 2, issue23133 can be considered as a dependency. -- dependencies: +Pickling of ipaddress classes ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23103 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23103] Reduce memory usage for ipaddress object instances
Nick Coghlan added the comment: I've retitled this issue to be specifically about reducing the memory consumption of the existing types in the IP Address module, as that's a change that isn't easily implemented externally, and shouldn't have any negative side effects under intended usage (although we should probably consider keeping __weakref__ support when adding the __slots__ definitions - I'm OK with taking away arbitrary attribute support, but far more wary of removing the existing weakref support) By contrast, interning for even more aggressive memory usage reduction is something that can be implemented relatively easily externally, and is also something that is really hard to tune in the general case. Small integers and strings that look like identifiers are a win because of the way the language itself works, but there's no similar general purpose heuristic that applies for caching of IP addresses. -- title: ipaddress should be Flyweight - Reduce memory usage for ipaddress object instances ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23103 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com