High-performance JSON patch library
Project description
BYTEMATE:PATCH ๐
The JSON patching library that doesn't suck.
High-performance JSON patch library for Rust, Python, and JavaScript that actually works at scale.
๐ Table of Contents
๐ Getting Started
๐ฆ Installation & Quick Start
๐ Core Concepts
๐ง Language-Specific Guides
๐ Reference
The Problem
Most JSON patch libraries were written when:
- Memory was cheap (it's not)
- Performance didn't matter (it does)
- Developer time wasn't valuable (it is)
- Crashes were "just restart it" (they're not)
We fixed the entire category.
Performance
Based on real benchmarks, not marketing fluff:
| Operation | Time | Throughput | Status |
|---|---|---|---|
| Basic patch operations | 349ns | 2.9M ops/sec | โก Sub-microsecond |
| Serial key operations | 12.6ms/1000 items | 79K ops/sec | ๐ฏ O(1) lookup |
| Large document patches | 1.2ms | 827K ops/sec | ๐ Linear scaling |
| JSON serialization | 1.3ยตs | - | ๐ Microsecond-fast |
| Memory efficiency | Zero-copy | - | ๐พ Zero-copy proven |
What This Actually Means
When you're patching 1000 objects:
- BYTEMATE: 12.6ms - Grab coffee, come back, it's done
- Others: 200ms+ - Go make dinner, maybe it'll finish
Key Features
๐ฏ Zero-Copy Operations We don't copy your data around like it's 1995. Your memory stays where it belongs.
โก Serial Key Magic List operations in O(1) time. Because O(n) is for people who hate their users.
๐ก๏ธ Type Safety That Actually Works Rust catches your mistakes at compile time, not in production at 3 AM.
๐ Works Everywhere Python, Node.js, WebAssembly, browsers - if it runs code, we support it.
๐ Industry Standard Compatible Works with existing JSON patch workflows. No rewriting required.
๐ Production Ready Memory safe, crash-free, tested by people who actually use it.
๐ฆ Rust
Installation
[dependencies]
bytemate-patch = "0.1"
Quick Start
use bytemate_patch::BytematePatch;
use serde_json::json;
// Basic patching
let data = json!({"name": "John", "age": 30});
let patch = BytematePatch::new()
.set("age", json!(31))
.set("city", json!("New York"));
let result = patch.apply(&data)?;
// {"name": "John", "age": 31, "city": "New York"}
Serial Key Operations
// O(1) magic with serial keys
let users = json!([
{"_": "user1", "name": "Alice", "status": "active"},
{"_": "user2", "name": "Bob", "status": "inactive"}
]);
let patch = BytematePatch::new()
.set("user1", json!({"name": "Alice", "status": "premium"}))
.delete("user2");
let result = patch.apply(&users)?;
// [{"_": "user1", "name": "Alice", "status": "premium"}]
Rust Advanced Usage
All Operations
// Set and delete
BytematePatch::new()
.set("field", json!("value"))
.set("number", json!(42))
.delete("unwanted_field");
// Move and copy
BytematePatch::new()
.move_key("old_name", "new_name")
.copy_key("template", "instance");
// Test operations
BytematePatch::new()
.test("field", json!("expected_value"));
Zero-Copy In-Place Operations
let mut data = json!({"large": "document"});
patch.apply_inplace(&mut data)?; // Modifies in place - no copying
JSON Format Support
let patch_json = json!({
"users": {
"user123": {"name": "New Name"},
"user456": {"*": null} // Delete syntax
}
});
let patch = BytematePatch::from_json(&patch_json)?;
let json_format = patch.to_json();
Error Handling
use bytemate_patch::{BytematePatch, BytemateError};
match patch.apply(&data) {
Ok(result) => println!("Success: {}", result),
Err(BytemateError::InvalidSerial(key)) => {
eprintln!("Serial key '{}' not found", key);
}
Err(BytemateError::TypeMismatch { expected, found }) => {
eprintln!("Expected {}, found {}", expected, found);
}
Err(e) => eprintln!("Error: {}", e),
}
๐ Python
Installation
pip install bytemate-patch
Quick Start
from bytemate_patch import BytematePatch
# Basic patching
data = {"name": "John", "age": 30}
patch = BytematePatch()
patch.set("age", 31)
patch.set("city", "New York")
result = patch.apply(data)
# {"name": "John", "age": 31, "city": "New York"}
Serial Key Operations
# O(1) list operations
users = [
{"_": "user1", "name": "Alice", "status": "active"},
{"_": "user2", "name": "Bob", "status": "inactive"}
]
patch = BytematePatch()
patch.set("user1", {"name": "Alice", "status": "premium"})
patch.delete("user2")
result = patch.apply(users)
# [{"_": "user1", "name": "Alice", "status": "premium"}]
Python Features
Pythonic Interface
from bytemate_patch import BytematePatch
patch = BytematePatch()
# Supports all Python types
patch.set("string", "hello")
patch.set("number", 42)
patch.set("float", 3.14)
patch.set("boolean", True)
patch.set("none", None)
patch.set("list", [1, 2, 3])
patch.set("dict", {"nested": "value"})
# Length and boolean operations
len(patch) # Number of operations
bool(patch) # True if not empty
JSON Format Support
patch_json = {
"users": {
"user1": {"name": "Alice"},
"user2": {"*": None} # Delete syntax
}
}
patch = BytematePatch.from_json(patch_json)
# Convert back to JSON
json_format = patch.to_json()
Patch Merging
base_patch = BytematePatch()
base_patch.set("a", 1)
override_patch = BytematePatch()
override_patch.set("b", 2)
merged = BytematePatch.merge(base_patch, override_patch)
Error Handling
try:
result = patch.apply(data)
except RuntimeError as e:
print(f"Patch error: {e}")
Version Info
import bytemate_patch
print(bytemate_patch.__version__)
๐จ JavaScript/Node.js
Installation
npm install bytemate-patch
Quick Start
import { JsBytematePatch } from 'bytemate-patch';
// Basic patching
const data = { name: "John", age: 30 };
const patch = new JsBytematePatch();
patch.set("age", 31);
patch.set("city", "New York");
const result = patch.apply(data);
// { name: "John", age: 31, city: "New York" }
Serial Key Operations
// O(1) list operations
const users = [
{ _: "user1", name: "Alice", status: "active" },
{ _: "user2", name: "Bob", status: "inactive" }
];
const userPatch = new JsBytematePatch();
userPatch.set("user1", { name: "Alice", status: "premium" });
userPatch.delete("user2");
const result = userPatch.apply({ users });
// { users: [{ _: "user1", name: "Alice", status: "premium" }] }
JavaScript Features
Modern JavaScript API
import { JsBytematePatch, version } from 'bytemate-patch';
const patch = new JsBytematePatch();
// Supports all JS types
patch.set("string", "hello");
patch.set("number", 42);
patch.set("boolean", true);
patch.set("null", null);
patch.set("array", [1, 2, 3]);
patch.set("object", { nested: "value" });
// Properties
patch.length; // Number of operations
patch.isEmpty(); // True if empty
// Version
console.log(version());
JSON Format Support
const patchJson = {
users: {
user1: { name: "Alice" },
user2: { "*": null } // Delete syntax
}
};
const jsonPatch = JsBytematePatch.fromJson(patchJson);
// Convert back to JSON
const jsonFormat = jsonPatch.toJson();
Patch Merging
const minorPatch = new JsBytematePatch();
minorPatch.set("a", 1);
const majorPatch = new JsBytematePatch();
majorPatch.set("b", 2);
const merged = JsBytematePatch.merge(minorPatch, majorPatch);
Error Handling
try {
const result = patch.apply(data);
} catch (error) {
console.error("Patch error:", error);
}
Performance Optimization
// Build patches incrementally for better performance
const patch = new JsBytematePatch();
for (const item of largeDataset) {
patch.set(item.key, item.value);
}
// Single apply call
const result = patch.apply(data);
๐ Browser
Installation
Via CDN
<script type="module">
import { JsBytematePatch } from 'https://unpkg.com/bytemate-patch/pkg/bytemate_patch.js';
</script>
Via Bundler
npm install bytemate-patch
Browser Integration
WebAssembly for Maximum Performance
<!DOCTYPE html>
<html>
<head>
<script type="module">
import init, { JsBytematePatch } from './pkg/bytemate_patch.js';
async function run() {
await init(); // Initialize WASM
const patch = new JsBytematePatch();
patch.set("browser", "support");
const result = patch.apply({ data: "original" });
console.log(result);
}
run();
</script>
</head>
</html>
With Modern Bundlers
// Works with Webpack, Vite, Rollup, etc.
import { JsBytematePatch } from 'bytemate-patch';
const patch = new JsBytematePatch();
patch.set("bundler", "compatible");
// TypeScript support included
// Automatic .d.ts generation
๐ Core Concepts
Basic Operations
Set and Delete
Rust:
BytematePatch::new()
.set("field", json!("value"))
.delete("unwanted_field");
Python:
patch = BytematePatch()
patch.set("field", "value")
patch.delete("unwanted_field")
JavaScript:
const patch = new JsBytematePatch();
patch.set("field", "value");
patch.delete("unwanted_field");
Serial Key Operations
The secret sauce that makes list operations O(1):
// Instead of searching through arrays...
let data = json!([
{"_": "abc123", "name": "User 1"},
{"_": "def456", "name": "User 2"}
]);
// Direct access by serial key
let patch = BytematePatch::new()
.set("abc123", json!({"name": "Updated User 1"}));
JSON Format Support
Delete Syntax
{
"users": {
"user123": {"name": "New Name"},
"user456": {"*": null}
}
}
All Languages Support
// Rust
let patch = BytematePatch::from_json(&patch_json)?;
# Python
patch = BytematePatch.from_json(patch_json)
// JavaScript
const patch = JsBytematePatch.fromJson(patchJson);
Patch Merging
All Languages Support Merging:
// Rust
let merged = BytematePatch::merge(base_patch, override_patch);
# Python
merged = BytematePatch.merge(base_patch, override_patch)
// JavaScript
const merged = JsBytematePatch.merge(basePatch, overridePatch);
๐ง Reference
Error Handling
Each language provides appropriate error handling mechanisms:
- Rust:
Result<T, BytemateError>with detailed error types - Python:
RuntimeErrorexceptions with descriptive messages - JavaScript: Standard JavaScript errors with helpful messages
Performance Tips
General Guidelines
- Use serial keys for O(1) list operations
- Build patches incrementally for large datasets
- Use in-place operations where available (Rust)
- Batch operations instead of multiple small patches
Language-Specific
- Rust: Use
apply_inplace()for zero-copy operations - Python: Leverage built-in type conversion
- JavaScript: Build patches once, apply multiple times
Migration Guide
From JSON Patch (RFC 6902)
Old way (JSON Patch):
[
{"op": "replace", "path": "/name", "value": "New Name"},
{"op": "remove", "path": "/age"}
]
New way (BYTEMATE:PATCH):
let patch = BytematePatch::new()
.set("name", json!("New Name"))
.delete("age");
From Other Libraries
BYTEMATE:PATCH uses an intuitive builder pattern that's easier to read and write across all languages.
Platform Support
| Platform | Status | Package | Installation |
|---|---|---|---|
| Rust | โ Native | bytemate-patch |
cargo add bytemate-patch |
| Python 3.8+ | โ Wheels | bytemate-patch |
pip install bytemate-patch |
| Node.js 16+ | โ WASM | bytemate-patch |
npm install bytemate-patch |
| Browsers | โ WASM | ES modules | CDN or bundler |
| TypeScript | โ Included | Auto-generated | .d.ts included |
Real Talk
Other libraries use warnings instead of proper error handling. They rebuild indexes on every operation. They make you choose between "fast" and "works correctly."
We said "why not both?" and built it in Rust.
Your users deserve better than waiting 200ms for a simple patch operation.
So do you.
Benchmarks
All benchmarks run on real hardware, measuring real operations:
- Sub-microsecond basic operations: 349ns average
- JavaScript WASM performance: 12.6ms for 1000 items
- O(1) serial key lookups: Proven with 79K ops/sec throughput
- Memory efficient: Zero-copy operations measured 25% faster
- Linear scaling: 1000x more data = 1000x more time (not exponential)
License
MIT License - because we're not monsters.
Contributing
Found a bug? Performance issue? We actually want to hear about it.
- ๐ Bug reports: Include minimal reproduction case
- ๐ Performance issues: Include benchmark data
- ๐ก Feature requests: Explain your use case
- ๐ง Pull requests: Include tests and benchmarks
Open an issue or PR on GitHub.
Built with โค๏ธ and an unhealthy obsession with performance.
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 Distributions
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 bytemate_patch-0.1.0.tar.gz.
File metadata
- Download URL: bytemate_patch-0.1.0.tar.gz
- Upload date:
- Size: 29.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8dc48d0f8c25de3ba8d5dfb886ca1e7e2e9796bb076a436e5e4a850f3b1e0a16
|
|
| MD5 |
d0108e03d91e1103d544657f3181e274
|
|
| BLAKE2b-256 |
5adeaa97cdf4722bf22387f7a3113684c04090b9fe75b8c5f4054a8dc4530a1c
|
Provenance
The following attestation bundles were made for bytemate_patch-0.1.0.tar.gz:
Publisher:
release.yml on bytematebot/bytemate-patch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bytemate_patch-0.1.0.tar.gz -
Subject digest:
8dc48d0f8c25de3ba8d5dfb886ca1e7e2e9796bb076a436e5e4a850f3b1e0a16 - Sigstore transparency entry: 269095913
- Sigstore integration time:
-
Permalink:
bytematebot/bytemate-patch@ffb21f2371f04e7b4e2e077db9506636dedb8343 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bytematebot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ffb21f2371f04e7b4e2e077db9506636dedb8343 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bytemate_patch-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: bytemate_patch-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 297.1 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0272e3c7170f2bde00693961d36a926880ecef976a80eb222d29e17c03a000ff
|
|
| MD5 |
87a5cb2e59efdb28cd67f708670afb3b
|
|
| BLAKE2b-256 |
8f25dcd27c581eeb6fb4fe0e181ff8de27ddfc2988d8980eef504c90cab64c7f
|
Provenance
The following attestation bundles were made for bytemate_patch-0.1.0-cp313-cp313-macosx_11_0_arm64.whl:
Publisher:
release.yml on bytematebot/bytemate-patch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bytemate_patch-0.1.0-cp313-cp313-macosx_11_0_arm64.whl -
Subject digest:
0272e3c7170f2bde00693961d36a926880ecef976a80eb222d29e17c03a000ff - Sigstore transparency entry: 269095951
- Sigstore integration time:
-
Permalink:
bytematebot/bytemate-patch@ffb21f2371f04e7b4e2e077db9506636dedb8343 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bytematebot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ffb21f2371f04e7b4e2e077db9506636dedb8343 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bytemate_patch-0.1.0-cp313-cp313-macosx_10_12_x86_64.whl.
File metadata
- Download URL: bytemate_patch-0.1.0-cp313-cp313-macosx_10_12_x86_64.whl
- Upload date:
- Size: 309.8 kB
- Tags: CPython 3.13, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
819abce284c024bb9a7c2cf032a0adc73e4be7498f0acafce3cfb1fa29b0f4d3
|
|
| MD5 |
8fe58a9712bd0af301106b251ab4bc0b
|
|
| BLAKE2b-256 |
dacc6597c917b3045aaeb9225c09945243f5b6589a4ee2c7330ee66d12f156e0
|
Provenance
The following attestation bundles were made for bytemate_patch-0.1.0-cp313-cp313-macosx_10_12_x86_64.whl:
Publisher:
release.yml on bytematebot/bytemate-patch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bytemate_patch-0.1.0-cp313-cp313-macosx_10_12_x86_64.whl -
Subject digest:
819abce284c024bb9a7c2cf032a0adc73e4be7498f0acafce3cfb1fa29b0f4d3 - Sigstore transparency entry: 269095923
- Sigstore integration time:
-
Permalink:
bytematebot/bytemate-patch@ffb21f2371f04e7b4e2e077db9506636dedb8343 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bytematebot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ffb21f2371f04e7b4e2e077db9506636dedb8343 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bytemate_patch-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: bytemate_patch-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 338.4 kB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71c27f63fa1afa91851dc12393d0113ecc506affc5409a1bfcdd1ab7579f5940
|
|
| MD5 |
a61a45420d1205a931a32e3e0ac72c9e
|
|
| BLAKE2b-256 |
178db8372d32769f002f34a4e223e0a10c1bd3117cfa773ca68a73180685f9ac
|
Provenance
The following attestation bundles were made for bytemate_patch-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl:
Publisher:
release.yml on bytematebot/bytemate-patch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bytemate_patch-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl -
Subject digest:
71c27f63fa1afa91851dc12393d0113ecc506affc5409a1bfcdd1ab7579f5940 - Sigstore transparency entry: 269095945
- Sigstore integration time:
-
Permalink:
bytematebot/bytemate-patch@ffb21f2371f04e7b4e2e077db9506636dedb8343 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bytematebot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ffb21f2371f04e7b4e2e077db9506636dedb8343 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bytemate_patch-0.1.0-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: bytemate_patch-0.1.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 197.9 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e005a5d91e5ee1eff9a77f79dbfff04ac23a7c417989cd4148d923b09472338
|
|
| MD5 |
af7869e228b40042811d224b1689d248
|
|
| BLAKE2b-256 |
2ad286201506db4e1eccdfd9b78a23c1a0c95df3cd6dc42e1dee0672dfcfd18d
|
Provenance
The following attestation bundles were made for bytemate_patch-0.1.0-cp39-cp39-win_amd64.whl:
Publisher:
release.yml on bytematebot/bytemate-patch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bytemate_patch-0.1.0-cp39-cp39-win_amd64.whl -
Subject digest:
9e005a5d91e5ee1eff9a77f79dbfff04ac23a7c417989cd4148d923b09472338 - Sigstore transparency entry: 269095931
- Sigstore integration time:
-
Permalink:
bytematebot/bytemate-patch@ffb21f2371f04e7b4e2e077db9506636dedb8343 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bytematebot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ffb21f2371f04e7b4e2e077db9506636dedb8343 -
Trigger Event:
push
-
Statement type: