[MERGE][RFC] Add simple revision serializer based on RIO.

John Arbash Meinel john at arbash-meinel.com
Mon May 11 15:00:11 BST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andrew Bennetts wrote:
> Alexander Belchenko wrote:
>> Andrew Bennetts пишет:
>>> Alexander Belchenko wrote:
>>> [...]
>>>> In the past I wrote Pyrex extension for bencode. But it was rejected 
>>>> by  Aaron, because its benefits was not clearly visible at that time.
>>> Cool, I might dig that up and take a look.
>> https://lists.ubuntu.com/archives/bazaar/2007q3/029755.html
> 
> Thanks!
> 
> -Andrew.

By the way, I would also push for Pyrex just for maintainability.

If you look at most of the Pyrex code I've written, it is pretty much
"C" code. The *huge* benefits are:

1) Exception handling 'for free'. Including putting the lines of .pyx
code into the traceback.

2) All the 'boilerplate' of exposing new types, and registering them
with python (in cross-platform compatible ways).

3) Argument parsing

4) Real OOP. You can define a 'cdef class Foo:' in Pyrex, which gives
you all the nice syntax of member functions, etc. And with a little care
to make sure your variables are defined as appropriate classes, Pyrex
can make sure your "cdef foo(self):" function gets called via:
  ((MyType *)self)->_py_f_foo(self)

Rather than via "PyObject_GetAttr(self, "foo")); PyObject_Call(myfoo,
PyTuple_Create())"


You have to be a bit more careful, because you can 'accidentally' create
a python object in the inner loop because you forgot a

cdef int i

At the top.

But in general, I find writing the Python boilerplate clumsy, and harder
to maintain than just defining the stuff in Pyrex.

Parsers work pretty well as a state machine class, so that is the route
I would go. (You can look at the dirstate code, and various other
locations for comparison.)

I did not look at Alexander's code. I think the argument was that making
1% of the code 10x faster only makes the code base 0.9% faster, and at
the time bencode didn't have a lot of performance critical use cases.

Changing the revision serializer would probably change that equation a
bit. (Especially for 'log'.)

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkoIL2oACgkQJdeBCYSNAAPBYQCg0GJK6d6d1fjYnwQdgt5YtAGA
7DsAoJ7YTr0rtj8EFnTGXsyqUfmyzwvm
=SwFg
-----END PGP SIGNATURE-----



More information about the bazaar mailing list