Apache Fury™(incubating) is a blazingly fast multi-language serialization framework powered by jit and zero-copy
Project description
Apache Fury™ Python
Apache Fury(incubating) is a blazingly-fast multi-language serialization framework powered by just-in-time compilation and zero-copy.
Important Announcement
Apache Fury has been renamed to Apache Fory starting from v0.11.0, please use pyfory instead.
For versions before 0.11, please use "fury" instead of "fory" in package names, imports, and dependencies, see Fury Docs for how to use Fury in older versions.
Install Pyfury
pip install pyfury
For 0.11+ version, please install pyfory instead:
pip install pyfory
Getting Started
Object graph serialization
from dataclasses import dataclass
import pyfory
class Foo:
name: str:
age: int
pyfory.register(Foo)
bytes = pyfory.serialize(Foo("Shawn", 30)) # Ultra-fast encoding
restored = pyfory.deserialize(bytes) # Instant decoding
Row format zero-copy serialization
public class Bar {
String f1;
List<Long> f2;
}
public class Foo {
int f1;
List<Integer> f2;
Map<String, Integer> f3;
List<Bar> f4;
}
RowEncoder<Foo> encoder = Encoders.bean(Foo.class);
Foo foo = new Foo();
foo.f1 = 10;
foo.f2 = IntStream.range(0, 1000000).boxed().collect(Collectors.toList());
foo.f3 = IntStream.range(0, 1000000).boxed().collect(Collectors.toMap(i -> "k"+i, i->i));
List<Bar> bars = new ArrayList<>(1000000);
for (int i = 0; i < 1000000; i++) {
Bar bar = new Bar();
bar.f1 = "s"+i;
bar.f2 = LongStream.range(0, 10).boxed().collect(Collectors.toList());
bars.add(bar);
}
foo.f4 = bars;
// Can be zero-copy read by python
BinaryRow binaryRow = encoder.toRow(foo);
// can be data from python
Foo newFoo = encoder.fromRow(binaryRow);
// zero-copy read List<Integer> f2
BinaryArray binaryArray2 = binaryRow.getArray(1);
// zero-copy read List<Bar> f4
BinaryArray binaryArray4 = binaryRow.getArray(3);
// zero-copy read 11th element of `readList<Bar> f4`
BinaryRow barStruct = binaryArray4.getStruct(10);
// zero-copy read 6th of f2 of 11th element of `readList<Bar> f4`
barStruct.getArray(1).getInt64(5);
RowEncoder<Bar> barEncoder = Encoders.bean(Bar.class);
// deserialize part of data.
Bar newBar = barEncoder.fromRow(barStruct);
Bar newBar2 = barEncoder.fromRow(binaryArray4.getStruct(20));
Python
@dataclass
class Bar:
f1: str
f2: List[pa.int64]
@dataclass
class Foo:
f1: pa.int32
f2: List[pa.int32]
f3: Dict[str, pa.int32]
f4: List[Bar]
encoder = pyfury.encoder(Foo)
foo = Foo(f1=10, f2=list(range(1000_000)),
f3={f"k{i}": i for i in range(1000_000)},
f4=[Bar(f1=f"s{i}", f2=list(range(10))) for i in range(1000_000)])
binary: bytes = encoder.to_row(foo).to_bytes()
foo_row = pyfury.RowData(encoder.schema, binary)
print(foo_row.f2[100000], foo_row.f4[100000].f1, foo_row.f4[200000].f2[5])
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 Distributions
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 pyfury-0.10.3-cp312-cp312-manylinux1_x86_64.whl.
File metadata
- Download URL: pyfury-0.10.3-cp312-cp312-manylinux1_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.12
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0a9a58f5f828adaed74fc43d9d8c60406411a34432826bababc492ff1a488ee
|
|
| MD5 |
2d7224a28032ae1b1752c2e250691aec
|
|
| BLAKE2b-256 |
e5971154f29600d0c23ad08622a355de27dc259a66862de603e21fb708e6ac02
|
File details
Details for the file pyfury-0.10.3-cp311-cp311-manylinux1_x86_64.whl.
File metadata
- Download URL: pyfury-0.10.3-cp311-cp311-manylinux1_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.11
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6aa40b269d0ad38c89b126614456ed7984f7f7f6dc1e3046f828aa959d85bc1
|
|
| MD5 |
ab73520c8c6096517dcc4480e58197c5
|
|
| BLAKE2b-256 |
1285af123033204a41583ece685928fcc3e9030dd979e27ab0f6ee43d82ae5c2
|
File details
Details for the file pyfury-0.10.3-cp310-cp310-manylinux1_x86_64.whl.
File metadata
- Download URL: pyfury-0.10.3-cp310-cp310-manylinux1_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.10
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e4a392fea4ab60c48ab7357e131cf7d582c69d59e7ce04bc4aa7e0efe647bb0
|
|
| MD5 |
5c79dc38c08ba1b42ba29a11e57faf2d
|
|
| BLAKE2b-256 |
4b48ef0f03f867f4f29b57eec22b57e731f9add895556423c41e75644d20e022
|