Skip to content

Commit c91edc6

Browse files
bumpies
1 parent cd01b67 commit c91edc6

File tree

5 files changed

+33
-15
lines changed

5 files changed

+33
-15
lines changed

Cargo.lock

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "radixtarget"
3-
version = "4.0.3"
3+
version = "4.0.4"
44
edition = "2024"
55
description = "Fast radix tree implementation for IP addresses and hostnames with target matching"
66
license = "GPL-3.0"
@@ -16,7 +16,7 @@ crate-type = ["rlib", "cdylib"]
1616
[dependencies]
1717
idna = "1.0.3"
1818
ipnet = "2.10"
19-
pyo3 = { version = "0.26", features = ["extension-module"] }
19+
pyo3 = { version = "0.27", features = ["extension-module"] }
2020
seahash = "4.1"
2121

2222
[dev-dependencies]

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,26 @@ rt.get("example.com") # None
5959
# Custom data nodes
6060
rt.add("evilcorp.co.uk", "custom_data")
6161
rt.get("www.evilcorp.co.uk") # "custom_data"
62+
63+
# Insertion returns unique identifier
64+
insertion_id = rt.insert("10.0.0.1/8")
65+
assert insertion_id == "10.0.0.0/8"
66+
67+
# Store custom data with any entry
68+
rt.insert("example.org", data={"tags": ["production"], "priority": 1})
69+
result = rt.get("api.example.org")
70+
# result contains your custom data: {"tags": ["production"], "priority": 1}
6271
```
6372

73+
## API Differences: Python vs Rust
74+
75+
Both APIs provide an `insert()` method that returns a unique string identifier for each entry (a normalized version of the hostname or IP address). However, the Python API includes additional functionality:
76+
77+
- **Rust**: `insert()` returns a string that uniquely identifies the insertion
78+
- **Python**: `insert()` also returns this unique identifier string, but additionally supports a `data=` parameter that allows you to store custom data of any Python type alongside the entry. When you later call `get()`, it returns your custom data instead of just the matched target string.
79+
80+
This makes the Python API more flexible for applications that need to associate metadata with targets, while the Rust API focuses on pure performance for lookups.
81+
6482
## Rust
6583

6684
### Installation

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "radixtarget"
3-
version = "4.0.3"
3+
version = "4.0.4"
44
description = "Fast radix tree for IP addresses and DNS names"
55
authors = [{name = "TheTechromancer"}]
66
license = {text = "GPL-3.0"}

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)