Skip to main content

serialise

this is a simple library to serialise and deserialise python objects. it can serialise any object given it has a serialiser written for it. Many python builtins already have serialisers

to create a serialiser you use the Serialiser class

here is an example (the default list serialiser but more friendly)

from serialiser import Serialiser, read_size, write_size, serialise, deserialise
from io import BytesIO
def list_serialiser(data: list)->bytes:
	# create a bytearray this is a more convient way of creating bytes
	rv = bytearray()
	# add the length of the list
	# write size writes an int
	rv.extend(write_size(len(data)))
	# for each element in the list add the serialised element
	for el in data: rv.extend(serialise(el))
	return bytes(rv)
def list_deserialiser(data: bytes)->list:
	# the serialiser in reverse
	# create a BytesIO which is a more convient way of reading bytes
	data = BytesIO(data)
	# first read the length
	length = read_size(data, "list length")
	# then deserialise length elements from the data and reutrn them in an array
	return [deserialise(data) for _ in range(length)]
# register the Serialiser by createing a new instance of the Serialiser class
Serialiser(
	list,
	list_serialiser,
	list_deserialiser
)

Release files for serialise 0.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for serialise 0.0.0
File Size Uploaded
serialise-0.0.0.tar.gz 8.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for serialise 0.0.0
File Interpreter ABI Platform
serialise-0.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.1 kB

Release files / serialise-0.0.0.tar.gz

Download URL serialise-0.0.0.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5bf89866ccff50cf42cda08d21959d8ac4f8aaf8c24c113060a53588fb0ebbdd
BLAKE2b-256 checksum
How to use checksums
6fadb59b3f7fb711274c4c4195fd9070ab0923231b2fdaea1ae0870d1566e11e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.1

Release files / serialise-0.0.0-py3-none-any.whl

Download URL serialise-0.0.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
45c06bb3d0b875af88b3a93dac70a8a066127318efd740ac926c28e14cd7fbe6
BLAKE2b-256 checksum
How to use checksums
e4341c52245d3b54956e196e857c9930577bb6f567b3a5e1835e41a26ca66781
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.1

Release history Release notifications | RSS feed

This release

0.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page