Giter Site home page Giter Site logo

serek's Introduction

What's this?

A Python module which implements PHP serialization. It is written in C, thus it should be faster than other, pure-Python implementations.

Why would you ever want to use PHP serialization in Python? (Intead of, say, JSON?) Well, if you have a system consisting of both Python and PHP parts, you may want to talk to the PHP parts in their own language. But, well, most likely you will use it when you have some old legacy PHP code, and want to build newer parts of the system in Python.

There's no release available yet. However, current code seems to be stable and was heavily used in production, so you might want to grab the source straight from the Mercurial repository if you're desperate.

After you import the module, you can use either PHP-like named functions: serialize and unserialize, or its Python-like equivalents: dumps and loads:

>>> import serek
>>> x = serek.dumps({1: "foo", "bar": [2, 4, 8]})
>>> x
'a:2:{i:1;s:3:"foo";s:3:"bar";a:3:{i:0;i:2;i:1;i:4;i:2;i:8;}}'
>>> x == serek.serialize({1: "foo", "bar": [2, 4, 8]})
True
>>> serek.loads(x)
{1: 'foo', 'bar': {0: 2, 1: 4, 2: 8}}

Object serialization is not supported (yet). The legacy PHP system that the author had to deal with doesn't use such things (fortunately!). BTW, an idea: Maybe substituting full-featured objects with nested dicts is doable and worth considering?

Installation

python setup.py build
sudo python setup.py install

serek's People

Contributors

vrok avatar

Watchers

 avatar James Cloos avatar

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.