Giter Club home page Giter Club logo

pyo3-prost's Introduction

fastproto

fastproto exposes Rust protobuf structs (generated by prost) to Python.

Both Rust and Python code share the same memory layout. Python code accessing a field [123, 456, 789] will get a reference to Vec instead of copying them to PyList.

Docs

# decoding (secs)
2021                             2023
Python:  14.008996680990094      Python:  0.3742136040236801
Rust  :  0.5708326659951126      Rust  :  0.47216512804152444

# encoding (secs)
2021                             2023
Python:  8.68384731200058        Python:  0.26067180099198595
Rust  :  0.3029898940003477      Rust  :  0.23681609996128827

===========
PythonTweet
===========
b'\n\x11Hi this is a text\x10\xfb\x99K"\x1b\n\x03Who\x12\x14https://example.com/*\x06@trump*\x06@obama'
===========
  RustTweet
===========
b'\n\x11Hi this is a text\x10\xfb\x99K"\x1b\n\x03Who\x12\x14https://example.com/*\x06@trump*\x06@obama'

All you need is adding a single line

.type_attribute(".", "#[::pyo3_prost::pyclass_for_prost_struct]")

to your prost or tonic build.

Example

  1. Go to examples/proto-gen and cargo run. This will generate examples/rupy_proto/src/app.rs.
  2. Go to examples/rupy_proto and cargo build --release.
  3. Move examples/rupy_proto/target/release/librupy_proto.so to examples/rupy_proto/rupy_proto.so.
  4. Run the bench cd examples/rupy_proto && PYTHONPATH=. python bench_{decode, encode}.py.

TODO

  • rename pyo3-prost
  • oneof fields
  • enum

pyo3-prost's People

Contributors

elbaro avatar

Stargazers

Peter Vrba avatar  avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

pypt you1024

pyo3-prost's Issues

Is this project dead?

Hi there,
I'm interested in exactly solving the problem this project addresses but I don't see active commits on the project. Is it still under development?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.