معرفی شرکت ها


attrs2bin-0.0.1


Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر

توضیحات

Binary serializer for attrs-based classes
ویژگی مقدار
سیستم عامل -
نام فایل attrs2bin-0.0.1
نام attrs2bin
نسخه کتابخانه 0.0.1
نگهدارنده []
ایمیل نگهدارنده []
نویسنده Francisco Vicent
ایمیل نویسنده franciscovicent@outlook.com
آدرس صفحه اصلی https://github.com/fvicent/attrs2bin
آدرس اینترنتی https://pypi.org/project/attrs2bin/
مجوز -
# attrs2bin `attrs2bin` is a Python library that lets you serialize/deserialize your [`attrs`](https://www.attrs.org/en/stable/)-based classes to/from a byte stream. It is compatible with Rust's [`bincode`](https://github.com/servo/bincode), so you can seralize objects in Python, send the resulting byte stream through a socket or any other transport and deserialize it back to a Rust object. It can also deserialize objects from a socket (see below). # Example `attrs2bin` provides just two simple funcions: `serialize()`, which takes an object and returns a byte stream, and `deserialize()`, that takes a byte stream and an `attrs`-based class and returns an object. ```import attr import attrs2bin @attr.s(auto_attribs=True) class Sprite: name: str x: int y: int my_sprite = Sprite("My sprite", 35, 70) serialized = attrs2bin.serialize(my_sprite) deserialized = attrs2bin.deserialize(serialized, Sprite) assert my_sprite == deserialized ``` # What can be serialized? Objects of any `attrs`-based class can be serialized, as long as all their fields have a type (using type annotations or `attr.ib(type=...)`). `attrs2bin` ships with serializer for the following types: * `int` * `float` * `bytes` * `str` * `bool` You can create and register your own serializers for specific types by creating a class that implements `attrs2bin.interfaces.ITypeSerializer` and calling `attrs2bin.register_serializer()`. # Deserializing from a socket Instead of `deserialize(bytes, cls)`, you can use `deserialize_from_socket(sck, cls)`, which will read the necessary bytes from a socket and return a Python object. `sck` must be any object that implements `attrs2bin.interfaces.IReadableSocket`. # Rust compatibility The serializers that ships with `attrs2bin` are all compatible with Rust's [`bincode`](https://github.com/servo/bincode) library. Keep under your pillow the following table in order to create compatible types between Python and Rust: | Python type | Rust type | | --------------------------- |:-------------:| | `int` / `attrs2bin.SignedInt` | `i64` | | `attrs2bin.UnsignedInt` | `u64` | | `float` / `attrs2bin.Float64` | `f64` | | `attrs2bin.Float32` | `f32` | | `bytes` | `Vec<u8>` | | `str` | `String` | | `bool` | `bool` |


نیازمندی

مقدار نام
- zope.interface
- zope.component
- attrs


زبان مورد نیاز

مقدار نام
>=3.6 Python


نحوه نصب


نصب پکیج whl attrs2bin-0.0.1:

    pip install attrs2bin-0.0.1.whl


نصب پکیج tar.gz attrs2bin-0.0.1:

    pip install attrs2bin-0.0.1.tar.gz