This is an automated email from the ASF dual-hosted git repository. chaokunyang pushed a commit to tag v0.10.3-post1 in repository https://gitbox.apache.org/repos/asf/fory.git
commit ce9bb4f70cda7b0b594c11f57bd97c3be2e06f93 Author: chaokunyang <[email protected]> AuthorDate: Mon Aug 18 19:47:24 2025 +0800 update pyfury 0.10.3 readme to avoid use --- .github/workflows/release.yaml | 8 --- python/README.md | 122 ++++++++++++++++++++++++++++++----------- 2 files changed, 89 insertions(+), 41 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index abcc87b30..23ec60c43 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -41,14 +41,6 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install bazel run: ./ci/run_ci.sh install_bazel - - name: Update version in setup.py - run: | - echo "GITHUB_REF: $GITHUB_REF" - tag=$(echo $GITHUB_REF | cut -d / -f 3) - echo "tag: $tag" - version=${tag:1} - echo "version $version" - ci/deploy.sh bump_py_version $version - name: Build a binary wheel run: | ci/deploy.sh install_pyarrow diff --git a/python/README.md b/python/README.md index 73704ab10..8cd3286a7 100644 --- a/python/README.md +++ b/python/README.md @@ -1,51 +1,107 @@ # Apache Fury™ Python -Fury is a blazingly-fast multi-language serialization framework powered by just-in-time compilation and zero-copy. +Apache Fury(incubating) is a blazingly-fast multi-language serialization framework powered by just-in-time compilation and zero-copy. -## Build Fury Python +## Important Announcement -```bash -cd python -pip install pyarrow==14.0.0 Cython wheel numpy pytest -pip install -v -e . -``` +**Apache Fury has been renamed to Apache Fory starting from v0.11.0, please use [pyfory](https://pypi.org/project/pyfory/) instead.** + +**For versions before 0.11, please use "fury" instead of "fory" in package names, imports, and dependencies, see [Fury Docs](https://fory.apache.org/docs/0.10/docs/introduction/) for how to use Fury in older versions**. -### Environment Requirements +## Install Pyfury -- python 3.6+ +``` +pip install pyfury +``` -## Testing +For `0.11+` version, please install pyfory instead: -```bash -cd python -pytest -v -s . ``` +pip install pyfory +``` + +## Getting Started -## Code Style +### Object graph serialization -```bash -cd python -# install dependencies fro styling -pip install black==22.1.0 flake8==3.9.1 flake8-quotes flake8-bugbear click==8.0.2 -# flake8 pyfury: prompts for code to be formatted, but not formatted -flake8 pyfury -# black pyfury: format python code -black pyfury +```python +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 ``` -## Debug +### Row format zero-copy serialization + +```java +public class Bar { + String f1; + List<Long> f2; +} + +public class Foo { + int f1; + List<Integer> f2; + Map<String, Integer> f3; + List<Bar> f4; +} -```bash -cd python -python setup.py develop +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)); ``` -- Use `cython --cplus -a pyfury/_serialization.pyx` to produce an annotated HTML file of the source code. Then you can - analyze interaction between Python objects and Python's C API. -- Read more: <https://cython.readthedocs.io/en/latest/src/userguide/debugging.html> +### Python + +```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] -```bash -FURY_DEBUG=true python setup.py build_ext --inplace -# For linux -cygdb build +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]) ``` --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
