[Patches] [ python-Patches-462190 ] New C module for quopri assist

noreply@sourceforge.net noreply@sourceforge.net
Tue, 18 Sep 2001 13:32:09 -0700


Patches item #462190, was opened at 2001-09-17 00:39
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=462190&group_id=5470

Category: Modules
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Brandon Long (blong42)
Assigned to: Nobody/Anonymous (nobody)
Summary: New C module for quopri assist

Initial Comment:
This patch adds a new module, quoted, and code in
quopri to use this module if it exists.  This module
implements quoted printable encoding and decoding based
on strings in C.  This was required by a recent project
of mine because 1MB quoted printable mail attachments
(sometimes chosen to send PDF and PS data) would take
40+ minutes to encode and decode using the standard
quopri python module.

----------------------------------------------------------------------

>Comment By: Brandon Long (blong42)
Date: 2001-09-18 13:32

Message:
Logged In: YES 
user_id=325633

Ok, this version handles invalid escape sequences the same
way, ie by leaving them as they were in the input stream.

My original reason for writing this was performance, and the
size of the input was already restricted to 1MB, hence the
chosen in memory encode/decode.  No one is likely to be
using the current version for anything even approaching that
size given the abysmal performance of the current version.
Given that 2.2 adds the decodestring and encodestring
versions, maybe we should have both, I'm not sure.  The new
mimelib module handles mail in memory, instead of using the
file like operations of the rfc822 module.  *shrug*

Using PyString in that fashion I don't think will save
anything... as the only external interfaces for that would
do a copy on create with PyString_FromStringAndSize(), and
then a realloc with the PyString_Resize() (though I could be
missing something in there).

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2001-09-18 11:46

Message:
Logged In: YES 
user_id=21627

The patch looks good to me. A couple of comments that may 
be worth consideration:
- if backwards compatibility is an objective, boundary 
cases should be analysed in more detail. E.g. it appears 
that the case of invalid escape sequences (=EI) is handled 
differently.
- the new module, when encoding one file into anothher, 
reads all data, whereas the old one would read line by 
line. Is that change desirable?
- the C code could avoid copying the string if it 
allocated a PyString right away, and adjusted it with 
_Resize when it is done.


----------------------------------------------------------------------

Comment By: Brandon Long (blong42)
Date: 2001-09-17 15:31

Message:
Logged In: YES 
user_id=325633

Ok, this new patch adds the code to binascii, b2a_qp and
a2b_qp.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-09-17 07:22

Message:
Logged In: YES 
user_id=6380

It would make more sense to add this as another pair of
encodings to the binascii module, which provides similar
support for binhex, base64, and uuencode.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=462190&group_id=5470