Re: [Python-Dev] Unicode charmap decoders slow

2005-10-04 Thread Martin v. Löwis
Tony Nelson wrote: > But is there really no way to say this fast in pure Python? The way a > one-to-one byte mapping can be done with "".translate()? Well, .translate isn't exactly pure Python. One-to-one between bytes and Unicode code points simply can't work. Just try all alternatives yoursel

Re: [Python-Dev] Unicode charmap decoders slow

2005-10-04 Thread Martin v. Löwis
Tony Nelson wrote: >>For decoding it should be sufficient to use a unicode string of >>length 256. u"\ufffd" could be used for "maps to undefined". Or the >>string might be shorter and byte values greater than the length of >>the string are treated as "maps to undefined" too. > > > With Unicode u

Re: [Python-Dev] Unicode charmap decoders slow

2005-10-04 Thread Tony Nelson
[Recipient list not trimmed, as my replies must be vetted by a moderator, which seems to delay them. :] At 11:48 PM +0200 10/4/05, Walter Dörwald wrote: >Am 04.10.2005 um 21:50 schrieb Martin v. Löwis: > >> Walter Dörwald wrote: >> >>> For charmap decoding we might be able to use an array (e.g. a

Re: [Python-Dev] Unicode charmap decoders slow

2005-10-04 Thread Tony Nelson
At 9:37 AM +0200 10/4/05, Walter Dörwald wrote: >Am 04.10.2005 um 04:25 schrieb [EMAIL PROTECTED]: > >>As the OP suggests, decoding with a codec like mac-roman or iso8859-1 is >>very slow compared to encoding or decoding with utf-8. Here I'm working >>with 53k of data instead of 53 megs. (Note: thi

Re: [Python-Dev] Static builds on Windows (continued)

2005-10-04 Thread Martin v. Löwis
Marvin wrote: > I built pythoncore and python. The resulting python.exe worked fine, but did > indeed fail when I tried to dynamically load anything (Dialog said: the > application terminated abnormally) Not sure what you are trying to do here. In your case, dynamic loading simply cannot work. Th

Re: [Python-Dev] Unicode charmap decoders slow

2005-10-04 Thread Martin v. Löwis
Walter Dörwald wrote: >> This array would have to be sparse, of course. > > > For encoding yes, for decoding no. [...] > For decoding it should be sufficient to use a unicode string of length > 256. u"\ufffd" could be used for "maps to undefined". Or the string > might be shorter and byte val

[Python-Dev] Static builds on Windows (continued)

2005-10-04 Thread Marvin
Earlier references: http://mail.python.org/pipermail/python-dev/2004-July/046499.html I want to be able to create a version of python24.lib that is a static library, suitable for creating a python.exe or other .exe using python's api. So I did as the earlier poster suggested, using 2.4.1 sources.

Re: [Python-Dev] Unicode charmap decoders slow

2005-10-04 Thread Walter Dörwald
Am 04.10.2005 um 21:50 schrieb Martin v. Löwis: > Walter Dörwald wrote: > >> For charmap decoding we might be able to use an array (e.g. a >> tuple (or an array.array?) of codepoints instead of dictionary. >> > > This array would have to be sparse, of course. For encoding yes, for decoding no.

Re: [Python-Dev] Unicode charmap decoders slow

2005-10-04 Thread M.-A. Lemburg
Walter Dörwald wrote: > Am 04.10.2005 um 04:25 schrieb [EMAIL PROTECTED]: > > >>As the OP suggests, decoding with a codec like mac-roman or >>iso8859-1 is very >>slow compared to encoding or decoding with utf-8. Here I'm working >>with 53k of >>data instead of 53 megs. (Note: this is a lapt

Re: [Python-Dev] Unicode charmap decoders slow

2005-10-04 Thread Martin v. Löwis
Walter Dörwald wrote: > For charmap decoding we might be able to use an array (e.g. a tuple > (or an array.array?) of codepoints instead of dictionary. This array would have to be sparse, of course. Using an array.array would be more efficient, I guess - but we would need a C API for arrays (to

Re: [Python-Dev] PEP 343 and __with__

2005-10-04 Thread Guido van Rossum
On 10/4/05, Jason Orendorff <[EMAIL PROTECTED]> wrote: > Right after I sent the preceding message I got a funny feeling I'm > wasting everybody's time here. I apologize. Guido's original concern > about speedy C implementation for locks stands. I don't see a good > way around it. OK. Our messag

Re: [Python-Dev] PEP 343 and __with__

2005-10-04 Thread Guido van Rossum
On 10/4/05, Jason Orendorff <[EMAIL PROTECTED]> wrote: > This: > > with EXPR as VAR: > BLOCK > > expands to this under PEP 342: > > _cm = contextmanager(EXPR) > VAR = _cm.next() > try: > BLOCK > except: > try: > _cm.throw(*sys.exc_info()) >

Re: [Python-Dev] PEP 343 and __with__

2005-10-04 Thread Jason Orendorff
Right after I sent the preceding message I got a funny feeling I'm wasting everybody's time here. I apologize. Guido's original concern about speedy C implementation for locks stands. I don't see a good way around it. By the way, my expansion of 'with' using coroutines (in previous message) was

Re: [Python-Dev] PEP 343 and __with__

2005-10-04 Thread Jason Orendorff
The argument I am going to try to make is that Python coroutines need a more usable API. > Try to explain the semantics of the with statement without referring to the > __enter__ and __exit__ methods, and then see if you still think they're > superfluous ;) > > The @contextmanager generator decora

Re: [Python-Dev] PEP 343 and __with__

2005-10-04 Thread Guido van Rossum
On 10/4/05, Nick Coghlan <[EMAIL PROTECTED]> wrote: > I was planning on looking at your patch too, but I was waiting for an answer > from Guido about the fate of the ast-branch for Python 2.5. Given that we have > patches for PEP 342 and PEP 343 against the trunk, but ast-branch still isn't > even

Re: [Python-Dev] PEP 343 and __with__

2005-10-04 Thread Nick Coghlan
Jason Orendorff wrote: > Phillip J. Eby writes: > >>You didn't offer any reasons why this would be useful and/or good. > > > It makes it dramatically easier to write Python classes that correctly > support 'with'. I don't see any simple way to do this under PEP 343; > the only sane thing to do

Re: [Python-Dev] PEP 343 and __with__

2005-10-04 Thread Nick Coghlan
Michael Hudson wrote: > I think 'as big as new-style classes' is probably an exaggeration, but > I'm glad my troll caught a few people :) I was planning on looking at your patch too, but I was waiting for an answer from Guido about the fate of the ast-branch for Python 2.5. Given that we have pa

Re: [Python-Dev] PEP 343 and __with__

2005-10-04 Thread Michael Hudson
"Phillip J. Eby" <[EMAIL PROTECTED]> writes: > At 07:02 PM 10/3/2005 +0100, Michael Hudson wrote: >>"Phillip J. Eby" <[EMAIL PROTECTED]> writes: >> >> > Since the PEP is accepted and has patches for both its implementation >> and a >> > good part of its documentation, a major change like this wou

Re: [Python-Dev] unifying str and unicode

2005-10-04 Thread Fredrik Lundh
James Y Knight wrote: > Your point would be much easier to stomach if the "str" type could > *only* hold 7-bit ASCII. why? strings are not mutable, so it's not like an ASCII string will suddenly sprout non-ASCII characters. what ends up in a string is defined by the string source. if you can

Re: [Python-Dev] Unicode charmap decoders slow

2005-10-04 Thread Walter Dörwald
Am 04.10.2005 um 04:25 schrieb [EMAIL PROTECTED]: > As the OP suggests, decoding with a codec like mac-roman or > iso8859-1 is very > slow compared to encoding or decoding with utf-8. Here I'm working > with 53k of > data instead of 53 megs. (Note: this is a laptop, so it's possible > that