yEnc implementation in Python, bit slow

I posted a while ago for some help with my word finder program, which is now
quite a lot faster than I could manage. Thanks to all who helped

This time, I've written a basic batch binary usenet poster in Python, but
encoding the data into yEnc format is fairly slow. Is it possible to improve
the routine any, WITHOUT using non-standard libraries? I don't want to have
to rely on something strange

Advertisements

On Tue, Aug 05, 2003 at 12:50:58AM +1000, Freddie wrote:
> Hi,
>
> I posted a while ago for some help with my word finder program, which is now
> quite a lot faster than I could manage. Thanks to all who helped
>
> This time, I've written a basic batch binary usenet poster in Python, but
> encoding the data into yEnc format is fairly slow. Is it possible to improve
> the routine any, WITHOUT using non-standard libraries? I don't want to have
> to rely on something strange

Python is pretty quick as long as you avoid loops that operate character
by character. Try to use functions that operate on longer strings.

Suggestions:

For the (x+42)%256 build a translation table and use str.translate.
To encode characters as escape sequences use str.replace or re.sub.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!