Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

prophy: fast serialization protocol

Project description

Pypi Package Version Supported Python Versions Documentation Status Coverage Status Travis-CI Build Status

Prophy is a statically typed, binary, tag-free, unpacked serialization protocol.

You can define message schema:

struct MyMsg
{
    u16 x<>;
};

generate codecs for chosen languages:

prophyc --python_out . --cpp_full_out . --cpp_out . test.prophy

and serialize data in Python:

>>> import test
>>> msg = test.MyMsg()
>>> msg.x[:] = [1, 2, 3]
>>> msg.encode('<')
'\x03\x00\x00\x00\x01\x00\x02\x00\x03\x00\x00\x00'
>>> print msg
x: 1
x: 2
x: 3

in C++:

#include <iostream>
#include <iterator>
#include "test.ppf.hpp"

int main()
{
    prophy::generated::MyMsg msg{{1, 2, 3}};
    std::vector<uint8_t> data = msg.encode();
    std::copy(data.begin(), data.end(), std::ostream_iterator<unsigned>(std::cout, " "));
    std::cout << '\n' << msg.print();
    return 0;
}
3 0 0 0 1 0 2 0 3 0 0 0
x: 1
x: 2
x: 3

again in C++ (half hand-rolled, compiler-dependent, but fastest option):

#include <iostream>
#include <iterator>
#include <cstdlib>
#include "test.pp.hpp"

int main()
{
    MyMsg* msg = static_cast<MyMsg*>(std::malloc(12));
    msg->num_of_x = 3;
    msg->x[0] = 1;
    msg->x[1] = 2;
    msg->x[2] = 3;
    std::copy((uint8_t*)msg, ((uint8_t*)msg) + 12, std::ostream_iterator<unsigned>(std::cout, " "));
    std::cout << '\n';
    return 0;
}
3 0 0 0 1 0 2 0 3 0 0 0

Documentation: http://prophy.readthedocs.org

Issues: https://github.com/aurzenligl/prophy/issues

Release history Release notifications

This version
History Node

1.1.1

History Node

1.1.0

History Node

1.0.2

History Node

1.0.1

History Node

1.0.0

History Node

0.8

History Node

0.7.8

History Node

0.7.7

History Node

0.7.6

History Node

0.7.5

History Node

0.7.4

History Node

0.7.3

History Node

0.7.2

History Node

0.7.1

History Node

0.7

History Node

0.6

History Node

0.5.1

History Node

0.5

History Node

0.4.2

History Node

0.4.1

History Node

0.4

History Node

0.3

History Node

0.2.5

History Node

0.2.4

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
prophy-1.1.1-py2.py3-none-any.whl (69.5 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Nov 14, 2017
prophy-1.1.1.tar.gz (152.4 kB) Copy SHA256 hash SHA256 Source None Nov 14, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page