Re: [Python-Dev] Crazy idea for str.join

2006-04-29 Thread Guido van Rossum
On 4/29/06, Josiah Carlson <[EMAIL PROTECTED]> wrote: > I understand the underlying implementation of str.join can be a bit > convoluted (with the auto-promotion to unicode and all), but I don't > suppose there is any chance to get str.join to support objects which > implement the buffer interface

Re: [Python-Dev] Crazy idea for str.join

2006-04-29 Thread Josiah Carlson
Thomas Heller <[EMAIL PROTECTED]> wrote: > > Fredrik Lundh wrote: > > Josiah Carlson wrote: > > > >> At least for the examples of buffers that I've seen, using the buffer > >> interface for objects that support it is equivalent to automatically > >> applying str() to them. This is, strictly spe

Re: [Python-Dev] Crazy idea for str.join

2006-04-29 Thread Thomas Heller
Fredrik Lundh wrote: > Josiah Carlson wrote: > >> At least for the examples of buffers that I've seen, using the buffer >> interface for objects that support it is equivalent to automatically >> applying str() to them. This is, strictly speaking, an optimization. > > >>> a = array.array("i",

Re: [Python-Dev] Crazy idea for str.join

2006-04-29 Thread Fredrik Lundh
Josiah Carlson wrote: > At least for the examples of buffers that I've seen, using the buffer > interface for objects that support it is equivalent to automatically > applying str() to them. This is, strictly speaking, an optimization. >>> a = array.array("i", [1, 2, 3]) >>> str(a) "

Re: [Python-Dev] Crazy idea for str.join

2006-04-29 Thread Josiah Carlson
Edward Loper <[EMAIL PROTECTED]> wrote: > > Nick Coghlan wrote: > > Edward Loper wrote: > >> This is incompatible with the recent proposal making str.join > >> automatically str-ify its arguments. i.e.: > >> > >>''.join(['a', 12, 'b']) -> 'a12b'. > >> > >> I don't feel strongly about either

Re: [Python-Dev] Crazy idea for str.join

2006-04-29 Thread Edward Loper
Nick Coghlan wrote: > Edward Loper wrote: >> This is incompatible with the recent proposal making str.join >> automatically str-ify its arguments. i.e.: >> >>''.join(['a', 12, 'b']) -> 'a12b'. >> >> I don't feel strongly about either proposal, I just thought I'd point >> out that they're mut

Re: [Python-Dev] Crazy idea for str.join

2006-04-29 Thread Nick Coghlan
Edward Loper wrote: > This is incompatible with the recent proposal making str.join > automatically str-ify its arguments. i.e.: > >''.join(['a', 12, 'b']) -> 'a12b'. > > I don't feel strongly about either proposal, I just thought I'd point > out that they're mutually exclusive. Doesn't a

Re: [Python-Dev] Crazy idea for str.join

2006-04-29 Thread Edward Loper
Josiah Carlson wrote: > [...] get str.join to support objects which > implement the buffer interface as one of the items in the sequence? > > Something like: > > y = 'hello world' > buf1 = buffer(y, 0, 5) > buf2 = buffer(y, 6) > print ''.join([buf1, buf2]) > > should print "h

[Python-Dev] Crazy idea for str.join

2006-04-29 Thread Josiah Carlson
I understand the underlying implementation of str.join can be a bit convoluted (with the auto-promotion to unicode and all), but I don't suppose there is any chance to get str.join to support objects which implement the buffer interface as one of the items in the sequence? Something like: