An alternative to Python's standard-library ipaddress module — originally built for the PyTCP stack, fully usable on its own.
Project description
PyTCP-net_addr
An alternative to Python's standard-library ipaddress module —
originally built for the PyTCP
TCP/IP stack, fully usable on its own.
from net_addr import Ip6Address, Ip4Network, MacAddress
Ip6Address("2001:db8::1").is_global # True
Ip4Network("10.0.0.0/24")[10] # Ip4Address("10.0.0.10")
MacAddress("02:00:00:00:00:07").is_multicast # False
Ip4Address("10.0.0.1") in Ip4Network("10.0.0.0/8") # True
Why
A correct, immutable, strict-parsing address library with no runtime
dependencies and a single clean exception tree — suitable for protocol
stacks, network tooling, and anywhere ipaddress is too loose or does
not give you hashable / orderable / MAC / wildcard / interface-address
value types.
Features
- Value types —
Ip4Address,Ip6Address,MacAddress,Ip4Network/Ip6Network,Ip4Mask/Ip6Mask,Ip4Wildcard/Ip6Wildcard(ACL / firewall, non-contiguous),Ip4IfAddr/Ip6IfAddr. - Immutable & efficient —
__slots__, hashable, totally ordered,@finalleaves; equality never crosses address families. - Multi-form constructors — string, integer,
bytes/bytearray/memoryview, copy, or unspecified, via one positional argument. - Strict parsing — POSIX
inet_ptononly; legacy octal / hex / short-form leniencies and hybrid MAC separators are rejected. - RFC-accurate classification — global / private / link-local / loopback / multicast / documentation / reserved; RFC 4007 IPv6 zone identifiers; IPv4-mapped, 6to4 and Teredo extraction.
- CIDR arithmetic —
subnets(),supernet(),address_exclude(),hosts(), RFC 4632summarize(), containment and overlap. - IPv6 interface-identifier generators — EUI-64, RFC 7217 stable-privacy, RFC 8981 temporary; solicited-node multicast and multicast-MAC mapping.
- Rich formatting — expanded form, MAC hyphen / Cisco notations, zero-padded radix, reverse-DNS PTR names.
- One exception tree — every failure is a
NetAddrErrorsubclass; never a bare builtin. - Fully typed — ships
py.typed(PEP 561); strict-mypy clean.
Installation
pip install PyTCP-net_addr
Stdlib-only. The optional Click argument types are an extra:
pip install "PyTCP-net_addr[cli]" # adds click; exposes the net_addr ClickType* params
Requirements
Python 3.14+ (the library uses PEP 695 generics and modern typing).
License
GPL-3.0-or-later. Part of the PyTCP project by Sebastian Majewski.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytcp_net_addr-3.0.5.tar.gz.
File metadata
- Download URL: pytcp_net_addr-3.0.5.tar.gz
- Upload date:
- Size: 41.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47e485bf311ae4525df500c9452017f017b3a7a41ebc8f48d083c0641af253ef
|
|
| MD5 |
d158563335d57768bdaef4836375194a
|
|
| BLAKE2b-256 |
986cadeae21bdb54eaab65491d2961820139e240d52a9a83214cf83fbfefbfd9
|
Provenance
The following attestation bundles were made for pytcp_net_addr-3.0.5.tar.gz:
Publisher:
publish.yml on ccie18643/PyTCP
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytcp_net_addr-3.0.5.tar.gz -
Subject digest:
47e485bf311ae4525df500c9452017f017b3a7a41ebc8f48d083c0641af253ef - Sigstore transparency entry: 1573913081
- Sigstore integration time:
-
Permalink:
ccie18643/PyTCP@d682ce505106eeb632a62e2ec88e6119d5e90fbb -
Branch / Tag:
refs/tags/net_addr-v3.0.5 - Owner: https://github.com/ccie18643
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d682ce505106eeb632a62e2ec88e6119d5e90fbb -
Trigger Event:
release
-
Statement type:
File details
Details for the file pytcp_net_addr-3.0.5-py3-none-any.whl.
File metadata
- Download URL: pytcp_net_addr-3.0.5-py3-none-any.whl
- Upload date:
- Size: 63.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81141c9b31bbc6c460d2cff24d4d57b3785e2828bbfd2519fbaa84aee31f1024
|
|
| MD5 |
5b6e690d3a159686f7437d6e0c61332d
|
|
| BLAKE2b-256 |
32308da825dd5f59b62f6956f7aa1738e5b05bac7bc91de53cbf5aff0c86cbbe
|
Provenance
The following attestation bundles were made for pytcp_net_addr-3.0.5-py3-none-any.whl:
Publisher:
publish.yml on ccie18643/PyTCP
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytcp_net_addr-3.0.5-py3-none-any.whl -
Subject digest:
81141c9b31bbc6c460d2cff24d4d57b3785e2828bbfd2519fbaa84aee31f1024 - Sigstore transparency entry: 1573913118
- Sigstore integration time:
-
Permalink:
ccie18643/PyTCP@d682ce505106eeb632a62e2ec88e6119d5e90fbb -
Branch / Tag:
refs/tags/net_addr-v3.0.5 - Owner: https://github.com/ccie18643
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d682ce505106eeb632a62e2ec88e6119d5e90fbb -
Trigger Event:
release
-
Statement type: