Skip to main content

Fast object serializer for Python

Project description

shibazuzke provides simple and fast object serialization. Usually shibazuzke generates smaller data than picke or JSON, and faster on both serialization and de-serialization. shibazuke is intended to be safely used for interprocess-communications, so hopefully de-serializing maliciously crafted data doesn’t harm.

Usage

dumps(obj)

Return the shibazuke representation of the object as a string.

loads(string)

Read a shibazuke object hierarchy from a string.

Exapmle

Here’s simple example of shibazuzke:

>>> import shibazuke
>>> data = ['abc', {1:(2,3,4)}]
>>> result = shibazuke.dumps(data)
>>> data == shibazuke.loads(result)
True

Limitations

  • Following type of Python objects could be serialized.

    int, long, str, unicode, tuple, list, dict

  • Number of objects to be serialized is limited to 2147483647.

  • Length of serialized string is limited to 2147483647.

  • Max depth of object graphs is limited to 100, and circular reference is not supported.

    >>> import shibazuke
    >>> list1 = []
    >>> list2 = [list1]
    >>> list1.append(list2)
    >>> shibazuke.dumps(list1)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "shibazuke.pyx", line 524, in shibazuke.dumps
      File "shibazuke.pyx", line 309, in shibazuke.Serializer.dumps
      File "shibazuke.pyx", line 300, in shibazuke.Serializer._build
      File "shibazuke.pyx", line 246, in shibazuke.Serializer._handle_list
      File "shibazuke.pyx", line 300, in shibazuke.Serializer._build
      File "shibazuke.pyx", line 246, in shibazuke.Serializer._handle_list
      File "shibazuke.pyx", line 300, in shibazuke.Serializer._build
      File "shibazuke.pyx", line 238, in shibazuke.Serializer._handle_list
    ValueError: Circular refecence([[[...]]])
    
  • Objectes can occur multiple times in the object tree to be serialized, but they are de-serialized as differect objects.

    >>> import shibazuke
    >>> list1 = []
    >>> list2 = [list1, list1]
    >>> result = shibazuke.dumps(list2)
    >>> serialized = shibazuke.loads(result)
    >>> serialized[0] is serialized[1]
    False
    

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

Shibazuke-0.1.0.zip (35.5 kB view hashes)

Uploaded Source

Built Distribution

Shibazuke-0.1.0-py2.6-win32.egg (18.8 kB view hashes)

Uploaded Source

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