Re: [Python-3000] PEP 3137: Immutable Bytes and Mutable Buffer

2007-09-27 Thread Walter Dörwald
Guido van Rossum wrote: > Please comment. > [...] > Conversions between bytes or buffer objects and str objects must > always be explicit, using an encoding. There are two equivalent APIs: > ``str(b, [, ])`` is equivalent to > ``b.encode([, ])``, and > ``bytes(s, [, ])`` is equivalent to > ``s.d

Re: [Python-3000] PEP 3137: Immutable Bytes and Mutable Buffer

2007-09-27 Thread Talin
Guido van Rossum wrote: > Thinking through the consequences, and noticing that using the array > module as an ersatz mutable bytes type is far from ideal, and > recalling a proposal put forward earlier by Talin, I floated the > suggestion to have both a mutable and an immutable bytes type. (This >

Re: [Python-3000] PEP 3137: Immutable Bytes and Mutable Buffer

2007-09-27 Thread Joel Bender
> **Open Issue:** I'm undecided on whether indexing bytes and buffer > objects should return small ints (like the bytes type in 3.0a1, and > like lists or array.array('B')), or bytes/buffer objects of length 1 > (like the str type). The latter (str-like) approach will ease porting > code from Pyth

Re: [Python-3000] PEP 3137: Immutable Bytes and Mutable Buffer

2007-09-27 Thread Alexandre Vassalotti
On 9/26/07, Alexandre Vassalotti <[EMAIL PROTECTED]> wrote: > I think indexing a bytes/buffer object should return an int. > I find this behavior more natural, to me, than using an > ord()-like function to extract values. I didn't known about the length-1 comparison issue when I wrote this. Person

Re: [Python-3000] PEP 3137: Immutable Bytes and Mutable Buffer

2007-09-27 Thread Nick Coghlan
Guido van Rossum wrote: > [PEP 3137] >>> **Open Issue:** I'm undecided on whether indexing bytes and buffer >>> objects should return small ints (like the bytes type in 3.0a1, and >>> like lists or array.array('B')), or bytes/buffer objects of length 1 >>> (like the str type). The latter (str-like

Re: [Python-3000] Immutable bytes -- looking for volunteer

2007-09-27 Thread Neil Schemenauer
Guido van Rossum <[EMAIL PROTECTED]> wrote: > However there's quite a bit of Python 2.x code around that manipulates > *bytes* in the guise of 8-bit strings, and it uses tests like "if s[0] >== 'x': ..." frequently. I think it would be useful to do a survey and see how much code would be affected

Re: [Python-3000] Extension: mpf for GNU MP floating point

2007-09-27 Thread Rob Crowther
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I've uploaded the latest code to http://umass.glexia.net/mpf.tar.bz2 Here's a quick rundown of supported functions and operations. The MPF() constructor accepts a string and an optional keyword argument, prec, specifying precision (as a Long). Suppo

Re: [Python-3000] PEP 3137: Immutable Bytes and Mutable Buffer

2007-09-27 Thread Joel Bender
> Making an iterator over an integer sequence acceptable in the > constructor strongly suggests that a byte sequence contains integers > between 0 and 255 inclusive, not length 1 byte sequences. > > And I think that's the cleanest conceptual model for them as well. A > byte sequence doesn't con

Re: [Python-3000] Immutable bytes -- looking for volunteer

2007-09-27 Thread Guido van Rossum
On 9/27/07, Neil Schemenauer <[EMAIL PROTECTED]> wrote: > Guido van Rossum <[EMAIL PROTECTED]> wrote: > > However there's quite a bit of Python 2.x code around that manipulates > > *bytes* in the guise of 8-bit strings, and it uses tests like "if s[0] > >== 'x': ..." frequently. > > I think it woul

Re: [Python-3000] PEP 3137: Immutable Bytes and Mutable Buffer

2007-09-27 Thread Guido van Rossum
I think I've been convinced that b[0] should return an int in range(256). To Joel Bender: octet is not, and never will be a technical term for Python. It is a silly standards body compromise. -- --Guido van Rossum (home page: http://www.python.org/~guido/) ___

Re: [Python-3000] PEP 3137: Immutable Bytes and Mutable Buffer

2007-09-27 Thread Guido van Rossum
I didn't miss it, and I don't disagree, I just don't think it has much bearing on the discussion (which is whether to go with this proposal at all). On 9/27/07, Talin <[EMAIL PROTECTED]> wrote: > Guido van Rossum wrote: > > Thinking through the consequences, and noticing that using the array > > m

Re: [Python-3000] PEP 3137: Immutable Bytes and Mutable Buffer

2007-09-27 Thread Guido van Rossum
On 9/27/07, Joel Bender <[EMAIL PROTECTED]> wrote: > First, please enforce that where these functions take a "string" > parameter that they require an octet or octet string (I couldn't find > what kinds of arguments these functions require in PEP 3118): > > >>> x = b'123*45' > >>> x.find(

Re: [Python-3000] PEP 3137: Immutable Bytes and Mutable Buffer

2007-09-27 Thread Jim Jewett
On 9/26/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > Comparisons > --- > The bytes and buffer types are comparable with each other and > orderable, so that e.g. b'abc' == buffer(b'abc') < b'abd'. I think bytes (regardless of length) should compare to integers, so that: b"" < -s

Re: [Python-3000] PEP 3137: Immutable Bytes and Mutable Buffer

2007-09-27 Thread Guido van Rossum
On 9/27/07, Jim Jewett <[EMAIL PROTECTED]> wrote: > On 9/26/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > > Comparisons > > --- > > > The bytes and buffer types are comparable with each other and > > orderable, so that e.g. b'abc' == buffer(b'abc') < b'abd'. > > I think bytes (regardl

Re: [Python-3000] PEP 3137: Immutable Bytes and Mutable Buffer

2007-09-27 Thread Larry Hastings
Guido van Rossum wrote: I think I've been convinced that b[0] should return an int in range(256). This made me feel funny. I stared at this for a while: b'a' != b'abcde'[0] ?!? b'a'[0] != b'a' ?!? Then I realized that making b[0] return an int simply makes bytes objects behave less li

Re: [Python-3000] Immutable bytes -- looking for volunteer

2007-09-27 Thread Greg Ewing
Gregory P. Smith wrote: > Would a special case in the b'x' comparison tests that knows how to > compare a len==1 bytes (mutable or not) object to an integer be > reasonable or just alternately confusing? Comparison isn't the only thing you might want to do with bytes. Doing this just for compariso

Re: [Python-3000] Unicode and OS strings

2007-09-27 Thread Nicholas Bastin
On 9/22/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > argc/argv does not exist on Windows (that you seem to see it > anyway is an illusion), and if it did exist, it would be characters, > not bytes. Of course it exists on Windows. argc/argv are defined by the C standard, and say what you wil

Re: [Python-3000] PEP 3137: Immutable Bytes and Mutable Buffer

2007-09-27 Thread Greg Ewing
Alexandre Vassalotti wrote: > Personally, I wouldn't mind writing either this: > >for b in bytes: > if b == b'a'[0]: >pass Well, I would mind, because it's needlessly verbose and inefficient. I still think that c'x' is the least bad solution. As long as we're wanting to write ar

Re: [Python-3000] PEP 3137: Immutable Bytes and Mutable Buffer

2007-09-27 Thread Greg Ewing
Nick Coghlan wrote: > However, I do think it may be worth having an additional iterator on > bytes and buffer objects: > >def fragments(self, size=1): # Could do with a better name I suggest dice(). :-) -- Greg Ewing, Computer Science Dept, +--+ Universi

Re: [Python-3000] PEP 3137: Immutable Bytes and Mutable Buffer

2007-09-27 Thread Greg Ewing
Larry Hastings wrote: > So now bytes are straddling the difference between strings and the other > mapping types: I think the main reason it seems that way is that we're using a string-like notation for a bytes literal. With b[i] returning an int, it really behaves just like any other sequence.

Re: [Python-3000] Unicode and OS strings

2007-09-27 Thread Martin v. Löwis
Nicholas Bastin schrieb: > On 9/22/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> argc/argv does not exist on Windows (that you seem to see it >> anyway is an illusion), and if it did exist, it would be characters, >> not bytes. > > Of course it exists on Windows. argc/argv are defined by th

Re: [Python-3000] Unicode and OS strings

2007-09-27 Thread Stephen Hansen
On 9/27/07, Nicholas Bastin <[EMAIL PROTECTED]> wrote: > > On 9/22/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > argc/argv does not exist on Windows (that you seem to see it > > anyway is an illusion), and if it did exist, it would be characters, > > not bytes. > > Of course it exists on Win

Re: [Python-3000] Unicode and OS strings

2007-09-27 Thread Nicholas Bastin
On 9/28/07, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > Nicholas Bastin schrieb: > > On 9/22/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > >> argc/argv does not exist on Windows (that you seem to see it > >> anyway is an illusion), and if it did exist, it would be characters, > >> not bytes