[RFC] Pyrex implementation for bencode

Alexander Belchenko bialix at ukr.net
Sun Aug 5 16:21:05 BST 2007


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

Hi,

I started to dive into Pyrex, and decided to write something simple and useful
for Bazaar project. I chose bencode because it's simple algorithm,
and plus in the past Martin said that we could use bencode for VersionedProperties.

I use benchmarks from BitTorrent-bencode-5.0.8 package. With generic benchmark data
I have about 5x-6x faster decode and more than 2.5x faster encode:

version     decode     encode
python     30.78ms    18.75ms
pyrex       5.31ms     7.03ms

For VersionedProperties I think I need rework benchmark to use dicts with
several (2-3) keys. Probably for shorter bencode strings decode in python will go
fast enough, so speed difference will be smaller.
But I think even 2-3x is better than nothing.
Of course for tags this difference will be too small, but for 10K-50K files
with VersionedProperties attached to entries in inventory we should have big win.

I attached my Pyrex source and tests for this implementation, and my adapted
benchmarks. Put bencode.py to the dir with this files to run benchmarks.

If you think that my work have sense to include in bzr.dev I will start to adapt
these sources for bzrlib. Also I need some hints about writing proper benchmark
for my implementation in bzrlib style.

- --
[µ]

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGterhzYr338mxwCURAl6qAKCNV/k4dUzl7AeD/ijOGF+zODTcoQCfecmG
DrJVP0U0gc2r2a2/lVbz8rE=
=ShX7
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bencode_c.pyx
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20070805/352d962e/attachment-0005.diff 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: setup.py
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20070805/352d962e/attachment-0006.diff 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test_bencode_c.py
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20070805/352d962e/attachment-0007.diff 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: benchmarkdata.py
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20070805/352d962e/attachment-0008.diff 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: benchmarkbencode.py
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20070805/352d962e/attachment-0009.diff 


More information about the bazaar mailing list