[PATCH] Pure python base85 fallback

Brendan Cully brendan at kublai.com
Tue Dec 30 12:14:12 CST 2008


On Tuesday, 30 December 2008 at 09:49, Dennis Brakhane wrote:
> Two minor suggestions:
> 
> On Tue, Dec 30, 2008 at 4:30 AM, Brendan Cully <brendan at kublai.com> wrote:
> > diff --git a/mercurial/fallbacks/base85.py b/mercurial/fallbacks/base85.py
> > [...]
> > +        for i in range(4, -1, -1):
> > +            rems[i] = _b85chars[word % 85]
> > +            word /= 85
> Better make this word //= 85, one thing less to modify when trying to
> get hg work with Python 3. Or does hg have to support Python 2.1?

No, just python 2.3 -- I'll fix this. We may have this kind of
division elsewhere too.

> > words = struct.unpack('>' + 'L' * longs, text[0:longs*4])
> 
> I'd think unpack('>%iL' % longs, text[0:longs*4]) would be slightly
> better here, as no long string has to be created and parsed (the same
> goes for pack)

good point.

> BTW, Matt said that all C code was once implemented in Python, so
> there probably is some base85 encoding.

I wrote the base85 C code. I did start with a python version, but I
lost it some time ago, hence this port from the C.


More information about the Mercurial-devel mailing list