-
-
Save sigmonsays/11c6f1b509770b848a52 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### FILE: test.proto | |
package test; | |
enum OpCode { | |
OP_ONE = 1; | |
OP_TWO = 2; | |
} | |
message Message { | |
// this works | |
// optional int32 op = 1 [ default = 1 ] ; | |
// this does not work | |
optional OpCode op = 1 [ default = OP_TWO ]; | |
} | |
##### FILE: test.py | |
#!/usr/bin/env python | |
import time | |
from lwpb.codec import MessageCodec | |
pb2file = './test.pb2' | |
codec = MessageCodec( pb2file=pb2file, typename='test.Message') | |
cnt = 10 | |
for n in [1,2]: | |
print n | |
# Iteration completes yet fails is strange ways. | |
sum([ n for n in xrange(cnt) ]) | |
t = time.time() | |
print 'hello', cnt | |
for n in xrange(cnt): | |
# encode | |
m = { | |
'foo' : 'foo.1' } | |
bin = codec.encode(m) | |
# decode | |
#m2 = codec.decode(bin) | |
#td = time.time() - t | |
#print '%d in %.2f sec' % (10, td) | |
print 'done' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment