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.

classification
Title: speed up some ipaddress properties
Type: performance Stage: resolved
Components: Library (Lib) Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: josh.r, ncoghlan, pitrou, pmoody, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2014-05-15 21:24 by pitrou, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ipaddr_props.patch pitrou, 2014-05-15 21:24 review
Messages (5)
msg218630 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2014-05-15 21:24
Some properties on IPv4Address and IPv6Address instantiate one or several network objects each time they are computed. Instead these characteristic networks can be computed once and for all at module import. Patch attached.

(note: the lru_cache() decorator seems to mitigate this in micro-benchmarks, but the common pattern is not to call .is_private on always the same address :-))
msg218974 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-05-23 15:02
May be move implementations to parent class? In any case the patch LGTM.
msg218999 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2014-05-23 21:10
> May be move implementations to parent class?

Docstrings are different, though.
msg219000 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-05-23 21:12
New changeset 7a28ab8f012f by Antoine Pitrou in branch 'default':
Issue #21513: Speedup some properties of IP addresses (IPv4Address, IPv6Address) such as .is_private or .is_multicast.
http://hg.python.org/cpython/rev/7a28ab8f012f
msg219002 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2014-05-23 21:12
Committed, thanks.
History
Date User Action Args
2022-04-11 14:58:03adminsetgithub: 65712
2014-05-23 21:12:52pitrousetstatus: open -> closed
resolution: fixed
messages: + msg219002

stage: patch review -> resolved
2014-05-23 21:12:30python-devsetnosy: + python-dev
messages: + msg219000
2014-05-23 21:10:14pitrousetmessages: + msg218999
2014-05-23 15:02:07serhiy.storchakasetmessages: + msg218974
2014-05-16 00:43:00josh.rsetnosy: + josh.r
2014-05-15 21:24:37pitroucreate