So I’m in the planning stages of a project where I’ll probably be doing some heavy lifting in Python and serving up the output through PHP. Obviously this will entail transmitting data between Python and PHP and while I haven’t had a chance to do performance testing to see if it’s worth it to save to a database, the only other option was to serialize the data to a file that PHP could parse quickly. Obviously, the output from serialize()
is going to be the fastest way to recieved the data.
While there already exists a Python set of classes that serializes (and serializes) Python data, it (a) didn’t handle objects and (b) was licensed under the GPL (rant to follow later), meaning I couldn’t use it for it’s intended purpose due to the closed source nature of my project.
I decided this was a good enough time to play around with git so I created a github repo here.
It could probably still use some more TLC in the object area, maybe a few more supported types, and unserialization functions would be nice.
I do feel it wasn’t bad for a few hours of hacking if I do say so myself.
The code for the module (should be in a phpserialize.py file) is as follows: