GithubHelp home page GithubHelp logo

yushiomote / perde Goto Github PK

View Code? Open in Web Editor NEW
24.0 3.0 1.0 3.87 MB

Python serialization framework powered by Rust

Home Page: https://yushiomote.github.io/perde

Rust 66.49% Python 32.47% Makefile 1.04%
serialization messagepack json toml yaml python typing dataclasses

perde's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

griels

perde's Issues

Serde edge cases

Compile error in serde

#[derive(Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
struct A {
    #[serde(flatten, skip_deserializing)]
    f: bool
}

This kind of error happens when the number of virtual fields (fields without skip and flatten) goes 0.

Testing

Remaining tests

  • example-like simple cases
  • multiple formats
  • compare with serde
  • some attributes
  • memory leak etc.
  • error cases
    • serialization
      • py-side errors
        • invalid arguments
        • schema vs object mismatch
      • rust-side errors
        • serialization error (unlikely)
    • deserialization
      • py-side
        • invalid arguments
      • rust-side
        • deserialization error (invalid format, type etc)
  • test with random data structures -> supposed to be done in a separate project

Failed dumps to json, got invalid type error

I'm using python 3.9

The class:

@dataclass
class TcUiMsg:
    Fairvalue: Optional[dict[str, Fv]] = None

Fv is an object.

use perde.json.dumps to dump

out_txt = perde.json.dumps(msg)

got error:
Exception has occurred: TypeError (note: full exception trace is shown but execution is paused at: _run_module_as_main)
invalid argument: cannot get generic type information: typing.Optional[dict]: cannot get generic type information: dict[str, None]: invalid value type in dict: None is not a type

the object can dumps with orjson (orjson dumps to bytes ...)

out_bytes = orjson.dumps(msg)
out_txt = out_bytes.decode("utf-8")

Publish

  • perde-core as Rust package
  • perde-json as Python package
  • perde-yaml as Python package
  • perde-msgpack as Python package

Installing per pip3 fails

When trying to pip3 install perde it fails with:

maturin failed
        Caused by: The following metadata fields in `package.metadata.maturin` section of Cargo.toml are removed since maturin 0.14.0: classifier, requires-python, please set them in pyproject.toml as PEP 621 specifies.
      Error running maturin: Command '['maturin', 'pep517', 'write-dist-info', '--metadata-directory', '/tmp/pip-modern-metadata-y8ss37ju', '--interpreter', '/usr/bin/python3']' returned non-zero exit status 1.
      Checking for Rust toolchain....
      Running `maturin pep517 write-dist-info --metadata-directory /tmp/pip-modern-metadata-y8ss37ju --interpreter /usr/bin/python3`

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.