Registry / devops / cached-ipaddress

cached-ipaddress

JSON →
library1.1.2pypypi✓ verified 81d ago

A thin caching wrapper around Python's ipaddress module that memoizes construction of IPv4Address, IPv6Address, IPv4Network, IPv6Network, and IPv4Interface/IPv6Interface objects to reduce overhead when the same addresses are parsed repeatedly. Current version 1.1.2, maintained actively, supports Python >=3.9.

pip install cached-ipaddress
INSTALL
IMPORT
SIG · CACHED-IPADDRESS
C
cached-ipaddress
devopspythonv1.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cached_ip_addresses
from cached_ipaddress import cached_ip_addresses
from cached_ipaddress import CachedIPv4Address
ipaddress
from cached_ipaddress import ipaddress
from cached_ipaddress import CachedIPv4Address

Import and use a cached IP address object. The caching is internal; no manual setup required.

from cached_ipaddress import CachedIPv4Address # Create a cached IPv4 address addr = CachedIPv4Address('192.168.1.1') print(addr) # 192.168.1.1 # Same string returns cached object (id may differ but equality holds) addr2 = CachedIPv4Address('192.168.1.1') print(addr == addr2) # True
Debug
Known issues
gotchaCached objects are not singletons across string values; they are only cached per string argument, but multiple calls with the same string may return different instances if the cache is cleared or if using different constructors (e.g., CachedIPv4Address vs ipaddress.IPv4Address).
fix
Use identical constructor for caching benefit; do not assume object identity with `is`, rely on `==`.
affects: all
gotchaThe cache is unbounded and stored in a dictionary keyed by the string representation. In long-running processes with many unique addresses, memory usage may grow without bound.
fix
Consider periodic cache clearing or using a bounded cache if memory is a concern (not built-in).
affects: all
Upgrade
Version history
1.1.2latest on PyPI · released May 27, 2026
Audit
Dependencies
ipaddressrequiredstdlib; cached-ipaddress wraps its classes
Agent activity
6 hits · last 30 days
node
6
Resources