Skip to main content

Serialize Arguments as Bytes!

Project description

Bytes Argument Serializer

import os, datetime
from byarse import Pickle
from byarse import BAS


bas = BAS(safe=True, len64=False) # Serializer/Deserializer


class Test: # Test class (for pickling)
    randomdata = os.urandom(16)


i = input("Read or write? (r/w)\n")


if i.lower().startswith('w'): # 'w'
    # ----
    # Serialize
    # ----
    with open('test', 'wb') as f:
        f.write(bas.s([
            'Hello, world!',
            b'Hello, world!',
            42,
            2.5,
            datetime.datetime.utcnow(),
            # Pickle(Test) # Will raise TypeError when read if safe mode is enabled.
        ]))
else: # 'r'
    # ----
    # Deserialize
    # ----
    with open('test', 'rb') as f:
        ua = bas.u(f.read()) # Unserialize

        for i in ua:
            print(type(i).__name__, ':', i) # Output: "type : argument" (ex. str : Hello, world!)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

byarse-1.1.0.tar.gz (2.9 kB view hashes)

Uploaded Source

Built Distribution

byarse-1.1.0-py3-none-any.whl (3.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page