Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Gregory P. Smith
On 10/8/07, Gregory P. Smith <[EMAIL PROTECTED]> wrote: > > > - add missing methods to PyBytes (for list, see the PEP and compare to > > what's already there) > > Committed revision 58493. (closes issue1261). fwiw - On py3k head on the x86 ubuntu feisty box i used to do the commit the following t

Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Greg Ewing
Luke Stebbing wrote: > I expect something spelled "lower" to try and transform an object > in-place, period. Too bad changing it to "lowered" would be such a > royal pain. Yes, those methods should probably have been called "lowered", "captitalized", etc. from the beginning, but the time machine w

Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Greg Ewing
Jim Jewett wrote: > I thought that was the reason to return self instead of None. That would be even more misleading, because you would get no warning that you had called a mutating method when you thought you were calling a non-mutating one. This is the reason that all the existing mutating meth

Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Guido van Rossum
ByteSequence. On 10/15/07, Brett Cannon <[EMAIL PROTECTED]> wrote: > On 10/15/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > On 10/15/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > > There's one thing that I forgot to add to PEP 3137. It's the removal > > > of the basestring type. I thin

Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Brett Cannon
On 10/15/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > On 10/15/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > There's one thing that I forgot to add to PEP 3137. It's the removal > > of the basestring type. I think this is a reasonable thing to do. > > Christian Heimes has a patch that do

Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Greg Ewing
Jim Jewett wrote: > On 10/12/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > >>On 10/12/07, Gregory P. Smith <[EMAIL PROTECTED]> wrote: >> >>>Should the mutable PyBytes_ (buffer) objects implement >>>the following methods inplace and return an additional reference to self? If they're to work in

Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Gregory P. Smith
> Anyways I'll be done with my patch to add the copying versions of the > methods later today. Stay tuned. > The PyBytes methods from PEP3137 have been implemented. Review as desired. http://bugs.python.org/issue1261 If its good as is, let me know and I can check that in if you don't want to

Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Gregory P. Smith
while trying to figure out what to update the common method docstrings to say I've come up with terms such as 'byte string' or 'byte buffer' but none of those are extra appealing to me to turn into an ABC name. other thoughts? On 10/15/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > On 10/15/

Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Guido van Rossum
On 10/15/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > There's one thing that I forgot to add to PEP 3137. It's the removal > of the basestring type. I think this is a reasonable thing to do. > Christian Heimes has a patch that does this cleanly. Anyone objecting, > please speak up now! And, q

Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Guido van Rossum
There's one thing that I forgot to add to PEP 3137. It's the removal of the basestring type. I think this is a reasonable thing to do. Christian Heimes has a patch that does this cleanly. Anyone objecting, please speak up now! -- --Guido van Rossum (home page: http://www.python.org/~guido/) _

[Python-3000] bytes vs array.array vs numpy.array

2007-10-15 Thread Colin J. Williams
[EMAIL PROTECTED] wrote: > Nick> I wouldn't mind seeing some iteration-in-C bit-bashing operations > Nick> in there eventually... > > Nick>data = bytes([x & 0x1F for x in orig_data]) > > This begins to make it look what you want is array.array or nump.array. > Python's arrays don't

Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Guido van Rossum
I am not going to explain this further if you still don't get it. These functions should not modify their argument, and return a copy of the same type as the original. I'm fine with new APIs that perform similar things in-place. --Guido On 10/15/07, Jim Jewett <[EMAIL PROTECTED]> wrote: > On 10

Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Luke Stebbing
On 10/15/07, Jim Jewett <[EMAIL PROTECTED]> wrote: > So would returning a different object. I expect a mutation operation > on an explicitly mutable object to mutate the object, instead of > creating something new. > > If it returns a new one, I can imagine doing something like: > > obj.inqueu

Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Adam Olsen
On 10/15/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > On 10/15/07, Jim Jewett <[EMAIL PROTECTED]> wrote: > > On 10/12/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > > On 10/12/07, Gregory P. Smith <[EMAIL PROTECTED]> wrote: > > > > > > - add missing methods to PyBytes (for list, see the P

Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Luke Stebbing
On 10/15/07, Jim Jewett <[EMAIL PROTECTED]> wrote: > If returning the original (but mutated) buffer is a problem, then > there is already a problem, because someone else could already mutate > the original. > > (Also note that for duck-typing, it should be OK if the new result > object is always im

Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Jim Jewett
On 10/15/07, Gregory P. Smith <[EMAIL PROTECTED]> wrote: > On 10/15/07, Terry Reedy <[EMAIL PROTECTED]> wrote: > > ...I would think that being able to edit in place would be a reason > > to use a buffer rather than (immutable) bytes. > I agree, thats a benefit of a mutable object. But I think th

Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Gregory P. Smith
On 10/15/07, Terry Reedy <[EMAIL PROTECTED]> wrote: > > > "Guido van Rossum" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > | > > > As I work on these.. Should the mutable PyBytes_ (buffer) objects > implement > | > > > the following methods inplace and return an additional refere

Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Gregory P. Smith
> > >> Also what about .replace() and .translate()? > > > > > >> If they are not done in place should they return a new buffer > (PyBytes_) > > >> object or a bytes (PyString_) object? [i'd say a buffer (PyBytes_)] > > > > > > They should return the same type as 'self'. > > > > My preference would

Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Terry Reedy
"Guido van Rossum" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | > > > As I work on these.. Should the mutable PyBytes_ (buffer) objects implement | > > > the following methods inplace and return an additional reference to self? | > | > > > .capitalize(), .center(), .expandtabs

Re: [Python-3000] Should PyString (new bytes type) accept strings with encoding?

2007-10-15 Thread Christian Heimes
Doh, the answer is in the PEP. Please ignore the other mail :) http://www.python.org/dev/peps/pep-3137/#constructors Christian ___ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://m

Re: [Python-3000] Should PyString (new bytes type) accept strings with encoding?

2007-10-15 Thread Guido van Rossum
Correct. Sorry. Here's an improved table that I'm also adding to the PEP: C name | 2.xrepr | 3.0a1 repr | 3.0a2 repr -+-++--- PyUnicode| unicode u"" | str "" | str "" PyString | str "" | str8 s"" |

Re: [Python-3000] Should PyString (new bytes type) accept strings with encoding?

2007-10-15 Thread Steven Bethard
On 10/15/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > C name| 2.x | 3.0a1 | 3.0a2 | > --+--++-+ > PyUnicode | unicode u"" | str "" | str "" | > PyString | str "" | str8 s"" | bytes

Re: [Python-3000] Should PyString (new bytes type) accept strings with encoding?

2007-10-15 Thread Guido van Rossum
On 10/15/07, Christian Heimes <[EMAIL PROTECTED]> wrote: > I'm working on the renaming of str8 -> bytes and bytes -> buffer. > PyBytes (old bytes, new buffer) can take a string together with an > encoding and an optional error argument: > > > >>> bytes(source="abc", encoding="ascii", errors="replac

[Python-3000] Should PyString (new bytes type) accept strings with encoding?

2007-10-15 Thread Christian Heimes
I'm working on the renaming of str8 -> bytes and bytes -> buffer. PyBytes (old bytes, new buffer) can take a string together with an encoding and an optional error argument: >>> bytes(source="abc", encoding="ascii", errors="replace") b'abc' >>> str(b"abc", encoding="ascii") 'abc' IMO this should

Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Guido van Rossum
On 10/15/07, Joel Bender <[EMAIL PROTECTED]> wrote: > Speaking from the protocol encoding/decoding view, and one where a > buffer is very similar to a list of small integers... > > >> Also what about .replace() and .translate()? > > > >> If they are not done in place should they return a new buffer

Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Joel Bender
Speaking from the protocol encoding/decoding view, and one where a buffer is very similar to a list of small integers... >> Also what about .replace() and .translate()? > >> If they are not done in place should they return a new buffer (PyBytes_) >> object or a bytes (PyString_) object? [i'd sa

Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Guido van Rossum
On 10/15/07, Jim Jewett <[EMAIL PROTECTED]> wrote: > On 10/12/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > On 10/12/07, Gregory P. Smith <[EMAIL PROTECTED]> wrote: > > > > > - add missing methods to PyBytes (for list, see the PEP and compare to > > > > > what's already there) > > > > As I wo

Re: [Python-3000] PEP 3137 plan of attack

2007-10-15 Thread Jim Jewett
On 10/12/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > On 10/12/07, Gregory P. Smith <[EMAIL PROTECTED]> wrote: > > > > - add missing methods to PyBytes (for list, see the PEP and compare to > > > > what's already there) > > As I work on these.. Should the mutable PyBytes_ (buffer) objects im