{ "info": { "author": "Andy Gayton", "author_email": "andy@thecablelounge.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 2.7" ], "description": "=========\nprotolite\n=========\n\nLightweight implementation of Google's Protocol Buffers in Python.\n\nIn benchmarks, the protolite encoder ran twice as fast as\nGoogle's. Using Python's ``timeit`` module, the same data for both APIs was\nencoded and decoded 10000 times. The lowest time of three attempts was\npicked for each::\n\n protobuf: 3.6064529418945312 seconds\n protolite: 1.7224960327148438 seconds\n\nIf we take the ratio of these two times we see that protolite was\nabout two times faster than its counterpart.\n\nSimilarly, using Pypy we get about twice the speed::\n\n protobuf: 0.807873010635376 seconds\n protolite: 0.4414529800415039 seconds\n\nThe ``benchmark`` directory in the github_ repository contains the files\nneeded to re-run the tests . In addition, you will need the protobuf\nPython_ library. Try it on your platform, but, keep your machine as quite\nas possible so as to not skew the results::\n\n PYTHONPATH=$PYTHONPATH:$(pwd) python benchmark/benchmark.py\n\nPass the --pypy flag if you want to use Pypy in order to warm up the\nPypy JIT compiler and get a more accurate result::\n\n PYTHONPATH=$PYTHONPATH:$(pwd) pypy benchmark/benchmark.py --pypy\n\nYou can also make changes to the ``benchmark/messages.proto`` file to create\nyour own tests. You'll need to re-compile the ``messages.py`` and\n``messages_pb2.py`` files in the ``benchmark`` directory afterwards by running\nthe ``make`` command inside the same directory. Of course, you will need protoc_\nto compile Google's version.\n\n\ndescription\n===========\n\nProtocol Buffers (protobuf_) is a data interchange format created by\nGoogle. protolite is a rewrite of its encoder and file generator\nspecifically created and optimized for Python. The encoder is\noptimized for speed taking the language's properties in mind. The\ngenerator aims to provide ease-of-use and compatibility with the\nlanguage. For example, messages are implemented using only\ndicts. Familiarity with protobuf is required in order to use protolite\neffectively.\n\n\ninstallation\n============\n\nYou can download and install protolite from pypi_ with pip::\n\n pip install python-protolite\n\nAlternatively, you can clone the repository containing the source code\nfrom github_ and install protolite via setuptools::\n\n git clone https://github.com/thelinuxkid/python-protolite.git\n cd python-protolite\n python setup.py install\n\nusage\n=====\n\ngenerating files\n----------------\n\nprotolite comes with a utility that generates Python files structured\nfor efficiency and readbility. After the installation you will have an\nexecutable file called ``python-protolitec``. Its most simple usage\ntakes two positional arguments. The first is a list of the protobuf\ndefinition files and the second a directory where to write the Python\nversion of those files::\n\n python-protolitec proto/*.proto python\n\nThe output files will retain the same file name as the source; only the\nextension will be changed. For example, the file ``proto/messages.proto``\nwill produce the file ``python/messages.py``. You can use the ``--help``\nflag to view the other options offered by ``python-protolitec``.\n\nencoding\n--------\n\nLet's say you have a protobuf file called ``messages.proto`` containing::\n\n message User {\n optional uint32 userID = 1;\n enum UserType {\n STANDARD = 0;\n ADMIN = 1;\n }\n optional UserType type = 2;\n }\n\n``python-protolite`` will create a Python module ``messages`` with a ``user``\nobject which has a ``decode`` and an ``encode`` method. To encode a\nmessage you would do something like::\n\n import messages\n\n msg_enc = {'user_id': 123, 'type': messages.user_type.STANDARD}\n data = messages.user.encode(msg_enc)\n\nAs you can see, ``python-protolite`` changes camel-case variable names to\nunderscore. On the other end, to decode the message you would do\nsomething similar::\n\n import messages\n\n msg_dec = messages.user.decode(data)\n\nThe variable msg_dec will be equal to msg_enc.\n\nprinting\n--------\n\nThe message objects also contain a pretty print method. Calling\n``message.user.pprint(msg_enc)`` would produce::\n\n {\n \"type\": \"STANDARD\",\n \"user_id\": 123\n }\n\n\nYou can pass the keyword argument ``stream`` to ``pprint`` to write to\na stream different than sys.stdout.\n\nparser\n======\n\nIf you download the source code from github_ you will see a\n``grammar`` directory at the root level. This directory contains all\nthe files used to create the parser and lexer in ``protolite.parser``,\nthe module used by ``python-protolitec`` to parse the protobuf\ndefinition files. If you are familiar with Antlr_ you can edit the\n``proto_lexer.g`` and ``proto_parser.g`` files in this directory to create a\nnew Python parser and/or lexer using the Antlr jar in the same directory::\n\n cd grammar\n java -jar antlr-3.1.3.jar -fo . proto_lexer.g\n java -jar antlr-3.1.3.jar -fo . proto_parser.g\n\nThis will create four files: ``proto_lexer.py``,\n``proto_lexer.tokens``, ``proto_parser.py`` and\n``proto_parser.tokens``. You can leave the \\*.tokens files where they\nare but move the \\*.py files to protolite/parser to use your new parser\nwith ``python-protolitec``. If you want to use a different version of\nAntlr do so at your own risk. You will likely need the new Antlr\nversion to match the Python runtime version in setup.py.\n\n.. _protobuf: https://code.google.com/p/protobuf\n.. _pypi: https://pypi.python.org/pypi/python-protolite\n.. _github: https://github.com/thelinuxkid/python-protolite\n.. _antlr: http://antlr3.org/\n.. _Python: https://pypi.python.org/pypi/protobuf\n.. _protoc: https://code.google.com/p/protobuf/downloads/list", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/thelinuxkid/python-protolite", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "protolite", "package_url": "https://pypi.org/project/protolite/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/protolite/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/thelinuxkid/python-protolite" }, "release_url": "https://pypi.org/project/protolite/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "(\"Lightweight implementation of Google's Protocol Buffers in Python\",)", "version": "0.1.0" }, "last_serial": 1732426, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "02dc774c6b77b7aa18d404ea34698ef9", "sha256": "fa9fa968606caf745c64ed17c4012fe201e2dd01ef4b01419616a0396b805ff3" }, "downloads": -1, "filename": "protolite-0.1.0.tar.gz", "has_sig": false, "md5_digest": "02dc774c6b77b7aa18d404ea34698ef9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 38696, "upload_time": "2015-09-22T00:09:09", "url": "https://files.pythonhosted.org/packages/d6/57/6ec78d0c4498cd3decdc0c06dfc5b9b959e6fd6f7e97869c6fdeb92e9774/protolite-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "02dc774c6b77b7aa18d404ea34698ef9", "sha256": "fa9fa968606caf745c64ed17c4012fe201e2dd01ef4b01419616a0396b805ff3" }, "downloads": -1, "filename": "protolite-0.1.0.tar.gz", "has_sig": false, "md5_digest": "02dc774c6b77b7aa18d404ea34698ef9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 38696, "upload_time": "2015-09-22T00:09:09", "url": "https://files.pythonhosted.org/packages/d6/57/6ec78d0c4498cd3decdc0c06dfc5b9b959e6fd6f7e97869c6fdeb92e9774/protolite-0.1.0.tar.gz" } ] }