Skip to main content

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 typesIp4Address, Ip6Address, MacAddress, Ip4Network / Ip6Network, Ip4Mask / Ip6Mask, Ip4Wildcard / Ip6Wildcard (ACL / firewall, non-contiguous), Ip4IfAddr / Ip6IfAddr.
  • Immutable & efficient__slots__, hashable, totally ordered, @final leaves; equality never crosses address families.
  • Multi-form constructors — string, integer, bytes / bytearray / memoryview, copy, or unspecified, via one positional argument.
  • Strict parsing — POSIX inet_pton only; 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 arithmeticsubnets(), supernet(), address_exclude(), hosts(), RFC 4632 summarize(), 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 NetAddrError subclass; 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytcp_net_addr-3.0.5.tar.gz (41.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytcp_net_addr-3.0.5-py3-none-any.whl (63.1 kB view details)

Uploaded Python 3

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

Hashes for pytcp_net_addr-3.0.5.tar.gz
Algorithm Hash digest
SHA256 47e485bf311ae4525df500c9452017f017b3a7a41ebc8f48d083c0641af253ef
MD5 d158563335d57768bdaef4836375194a
BLAKE2b-256 986cadeae21bdb54eaab65491d2961820139e240d52a9a83214cf83fbfefbfd9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytcp_net_addr-3.0.5.tar.gz:

Publisher: publish.yml on ccie18643/PyTCP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for pytcp_net_addr-3.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 81141c9b31bbc6c460d2cff24d4d57b3785e2828bbfd2519fbaa84aee31f1024
MD5 5b6e690d3a159686f7437d6e0c61332d
BLAKE2b-256 32308da825dd5f59b62f6956f7aa1738e5b05bac7bc91de53cbf5aff0c86cbbe

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytcp_net_addr-3.0.5-py3-none-any.whl:

Publisher: publish.yml on ccie18643/PyTCP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page