I've been experimenting with protocol buffers on appengine, using
2.3.0. I am trying to basically find the fastest way to serialize a
dictionary, and would like to see if protobuf can improve on
performance I'm seeing with other methods (pickle - ick, simplejson -
better, repr - best so far).

I did a search around on the group and saw this thread from 2008:

The last post included what appeared to be suggested code for
implementing a python dictionary style data structure with protobuf:

 message Foo {
    optional string name = 1;
    optional int32 some_field = 2;
  message Bar {
    repeated Foo foo = 1 [experimental_map_key = "name"];

I tried this out in the hopes it might just work as is, but perhaps
predictably enough I run into problems - if I try to use string keys,
it complains (at runtime) that "list indices must be integers". I kind
of need my keys to be strings (otherwise I wouldn't really need a
dict...), but out of curiousity I switched to integers and tried
again, this time getting the error "list index out of range". It
throws this for any integer index I use.

I guess there might have been a hint in 'experimental' ... :) But is
there anything more I should try before giving up on this? Is there an
alternative way to approach this? My requirements are that a message
'instance' needs to accommodate an unknown number of key-value pairs
with unknown keys...maybe there's another way to do this?

Thanks for any help, it'd be greatly appreciated.

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to