[pypy-dev] binascii.py in pure python

Florian Bauer bauflo3 at web.de
Fri Nov 26 16:40:18 CET 2004


Christian Tismer wrote:

> holger krekel wrote:
>
>> Hi Florian,
>> [Florian Bauer Thu, Nov 25, 2004 at 04:53:33PM +0100]
>>
>>> Hi there,
>>>
>>> I checked the list of missing C modules on the wiki pages.
>>> I could contribute some code for binascii.py. 
>>
>>
>>
>> nice.
>>
>>> Some time ago i started porting the C module to python.
>>> It's halfway done, but some functions are pretty usable and have 
>>> some test coverage.
>>> Right now, I don't have time to download pypy and play with it, so I 
>>> don't know if there are any issues with integrating my code. It 
>>> would be best if I could develop and test the module on CPython.
>>
>>
>>
>> that's just fine.  Actually it's faster <wink> to develop against 
>> CPython  and
>> not let the current PyPy interpret your application level code.  
>
>
> As an addition:
> I'm just busy figuring out how to make C modules which are implemented
> in Python easier to compile back to C.
> It turned out that there is only little to change if your
> implementation does not use fancy features like generators.
> If you can assume that
> - all your globals are constant after initialization
> - you don't use ints or longs larger than machine words
> - methods are constants and not shadowed by instance vars
> - exceptions are raised only if you provide a try statement
> - no generators
> - no imports of modules which don't obey these rules
> - use __all__ to report the exports
>
> then this module is almost ready to become a builtin module.
> I just have to convert the exported objects in __all__
> an give them an application-python interface, again.
>
> ciao - chris

This is pretty trivial in the case of binascii.py. The interface assumes 
strings, not iterables, so there's no need for fancy stuff.
What I'm thinking about is whether I should use regular expressions or 
not. I haven't played around with it yet, but I guess that at least for 
running under CPython re.sub woud be faster than a state machine with 
the loop coded in python. But in pypy, maybe not. Any thoughts on this 
matter?

Btw. I will need some time to clean up the module. In the next 10 days 
I'm pretty busy with matching the deadline for my thesis <wink>.
But afterwards, I'll clean up my code and submit it.

Florian




More information about the Pypy-dev mailing list