speed - python implementation

411 views
Skip to first unread message

andres

unread,
Oct 27, 2008, 1:47:48 PM10/27/08
to Protocol Buffers
Hi,

I would like to use protocol buffers in my python code but currently
the serialization and parsing methods are too slow compared to
cPickle. I've read several posts stating that this is because the
python implementation has not been optimized for speed yet. Are there
plans to improve the performance of proto buffers in python? Does
anybody know of a C++ extension/wrapper module which lets you access C+
+ compiled protocol buffers directly from python code?

Thanks,
Andres

Kenton Varda

unread,
Oct 27, 2008, 5:34:35 PM10/27/08
to andres, Petar Petrov, Protocol Buffers
[+petar]

Jeremy Leader

unread,
Oct 28, 2008, 1:40:41 PM10/28/08
to andres, Protocol Buffers
Might it be possible to use the XS wrappers generated by protobuf-perlxs
from Python?

--
Jeremy Leader
jle...@oversee.net

Jeremy Leader

unread,
Oct 28, 2008, 2:11:02 PM10/28/08
to andres, Protocol Buffers
Jeremy Leader wrote:
> Might it be possible to use the XS wrappers generated by protobuf-perlxs
> from Python?

Aaah, not enough caffeine yet. I somehow confused XS (Perl-specific)
with SWIG (supports Perl, Python, and many others). Never mind!

--
Jeremy Leader
jle...@oversee.net

Petar Petrov

unread,
Oct 30, 2008, 2:19:25 PM10/30/08
to andres, Protocol Buffers
On Mon, Oct 27, 2008 at 10:47 AM, andres <andres...@gmail.com> wrote:

Hi,

I would like to use protocol buffers in my python code but currently
the serialization and parsing methods are too slow compared to
cPickle. I've read several posts stating that this is because the
python implementation has not been optimized for speed yet. Are there
plans to improve the performance of proto buffers in python?

Yes, there are plans to improve performance. I have spent a little time on this without significant improvements.
I think performance can hardly get a drastic improvement without a C++ extension module (which we are planning to have).

codeazure

unread,
Nov 9, 2008, 8:14:27 PM11/9/08
to Protocol Buffers
On Oct 31, 5:19 am, "Petar Petrov" <pesho.pet...@gmail.com> wrote:
> Yes, there are plans to improve performance. I have spent a little time on
> this without significant improvements.
> I think performance can hardly get a drastic improvement without a C++
> extension module (which we are planning to have).

Are you aware of anyone doing any work on a C++ Boost::Python
interface for PB? This would seem to be a relatively easy thing to
write, implementing the __getattr__/__setattr__ Python methods in
Boost::Python to interface to the reflection mechanism in PB.

If noone else is doing it, I might try this myself & pass it on if it
works.

Regards,
Jeff

Petar Petrov

unread,
Nov 12, 2008, 1:04:58 PM11/12/08
to codeazure, Protocol Buffers
On Sun, Nov 9, 2008 at 5:14 PM, codeazure <code...@gmail.com> wrote:

On Oct 31, 5:19 am, "Petar Petrov" <pesho.pet...@gmail.com> wrote:
> Yes, there are plans to improve performance. I have spent a little time on
> this without significant improvements.
> I think performance can hardly get a drastic improvement without a C++
> extension module (which we are planning to have).

Are you aware of anyone doing any work on a C++ Boost::Python
interface for PB?

No, we aren't aware of such.
 
This would seem to be a relatively easy thing to
write, implementing the __getattr__/__setattr__ Python methods in
Boost::Python to interface to the reflection mechanism in PB.

A few things. The current Python API has to remain pure-Python because some clients aren't able to use C/C++ extensions (like AppEngine).
Boost is generally not accepted in Google, so a Boost::Pythonit interface will have to distribute separately.

We are planning a Python C extension. It will likely consist of a separate python code generator to create Python code which wraps the C++
API and provides Python API similar to the current pure-Python protobuf API.

daveb

unread,
Nov 12, 2008, 8:43:07 PM11/12/08
to Protocol Buffers
you could consider wrapping protobuf-c... that will at least save you
the hassle of writing the C wrapper around C++.

- dave

On Nov 12, 10:04 am, "Petar Petrov" <pesho.pet...@gmail.com> wrote:

codeazure

unread,
Nov 12, 2008, 11:58:54 PM11/12/08
to Protocol Buffers
On Nov 13, 5:04 am, "Petar Petrov" <pesho.pet...@gmail.com> wrote:
> A few things. The current Python API has to remain pure-Python because some
> clients aren't able to use C/C++ extensions (like AppEngine).
> Boost is generally not accepted in Google, so a Boost::Pythonit interface
> will have to distribute separately.
>
> We are planning a Python C extension. It will likely consist of a separate
> python code generator to create Python code which wraps the C++
> API and provides Python API similar to the current pure-Python protobuf API.

Thanks for your feedback. I can see that for the official Python
support, this makes a lot of sense. You want to make it possible for
as wide a group of users as possible to use it. I'll look forward to
seeing how this development goes.

But I will do some experimentation with Boost::Python as this is a
much more convenient tool for C++ developers. If it works out, I will
make it available for others doing similar development. My current
application uses a very large Python::Boost definition defining my
API, with every variable and function explicitly defined. By changing
it to use a generic Message interface with reflection, I can
drastically simplify this Python/C++ gateway.

One of the things I like about PB is its portability and this is a
great example of how different solutions can be useful in various
situations.

Regards,
Jeff
Reply all
Reply to author
Forward
0 new messages