Re: [Python-Dev] ABC issues

2008-05-27 Thread Guido van Rossum
On Mon, May 26, 2008 at 11:59 AM, Raymond Hettinger <[EMAIL PROTECTED]> wrote: >> * The 2.6-backported Mapping ABC has the 3.0 dict API, >> that is, it uses keys() that returns a view etc. > > Curious to hear what Guido thinks about this one. > A nice use of the Mapping ABC is to be able to > get

Re: [Python-Dev] ABC issues

2008-05-27 Thread Guido van Rossum
On Mon, May 26, 2008 at 4:11 PM, Raymond Hettinger <[EMAIL PROTECTED]> wrote: >>> Deque's do not support count(), insert() or __iadd__(). >>> They should not be registered. > >> If it doesn't implement the MutableSequence protocol it still is a Sized >> container. However currently it's not regist

Re: [Python-Dev] Why is type_modified() in typeobject.c not a public function?

2008-05-27 Thread Guido van Rossum
I'm fine with giving it a public interface. Please submit a patch with docs included. On Tue, May 27, 2008 at 9:47 AM, Stefan Behnel <[EMAIL PROTECTED]> wrote: > [reposting this to python-dev, as it affects both 2.6 and 3.0] > > Hi, > > when we build extension classes in Cython, we have to first b

Re: [Python-Dev] ABC issues

2008-05-27 Thread Raymond Hettinger
* The 2.6-backported Mapping ABC has the 3.0 dict API, that is, it uses keys() that returns a view etc. Curious to hear what Guido thinks about this one. A nice use of the Mapping ABC is to be able to get 3.0 behaviors. I thought that was the whole point of all these backports. If the ABC get

Re: [Python-Dev] optimization required: .format() is much slower than %

2008-05-27 Thread Christian Heimes
Antoine Pitrou schrieb: > In order to avoid memory consumption issues there could be a centralized cache > as for regular expressions. It makes it easier to handle eviction based on > various parameters, and it saves a few bytes for string objects which are > never > used as a formatting template.

Re: [Python-Dev] optimization required: .format() is much slower than %

2008-05-27 Thread Eric Smith
Christian Heimes wrote: Antoine Pitrou schrieb: In order to avoid memory consumption issues there could be a centralized cache as for regular expressions. It makes it easier to handle eviction based on various parameters, and it saves a few bytes for string objects which are never used as a form

Re: [Python-Dev] ABC issues

2008-05-27 Thread Guido van Rossum
On Tue, May 27, 2008 at 10:44 AM, Raymond Hettinger <[EMAIL PROTECTED]> wrote: * The 2.6-backported Mapping ABC has the 3.0 dict API, that is, it uses keys() that returns a view etc. >>> >>> Curious to hear what Guido thinks about this one. >>> A nice use of the Mapping ABC is to be able

Re: [Python-Dev] ABC issues

2008-05-27 Thread Raymond Hettinger
If you want to use the 3.0 mixins in 2.6, perhaps an alternate set of APIs could be imported from the future? E.g. from future_collections import Mapping. IIRC a similar mechanism was proposed for some built-in functions, even though I see no traces of an implementation yet. Any know what happen

Re: [Python-Dev] ABC issues

2008-05-27 Thread Armin Ronacher
Hi, Guido van Rossum python.org> writes: > There's no need to register as Sized -- the Sized ABC recognizes > classes that define __len__ automatically. The Container class does > the same looking for __contains__. Since the deque class doesn't > implement __contains__, it is not considered a Co

[Python-Dev] Iterable String Redux (aka String ABC)

2008-05-27 Thread Armin Ronacher
Hi, Strings are currently iterable and it was stated multiple times that this is a good idea and shouldn't change. While I still don't think that that's a good idea I would like to propose a solution for the problem many people are experiencing by introducing an abstract base class for strings.

Re: [Python-Dev] ABC issues

2008-05-27 Thread Guido van Rossum
On Tue, May 27, 2008 at 12:16 PM, Armin Ronacher <[EMAIL PROTECTED]> wrote: > Hi, > > Guido van Rossum python.org> writes: > >> There's no need to register as Sized -- the Sized ABC recognizes >> classes that define __len__ automatically. The Container class does >> the same looking for __contains

Re: [Python-Dev] Iterable String Redux (aka String ABC)

2008-05-27 Thread Guido van Rossum
[+python-3000] On Tue, May 27, 2008 at 12:32 PM, Armin Ronacher <[EMAIL PROTECTED]> wrote: > Strings are currently iterable and it was stated multiple times that this is a > good idea and shouldn't change. While I still don't think that that's a good > idea I would like to propose a solution for

Re: [Python-Dev] Iterable String Redux (aka String ABC)

2008-05-27 Thread Benji York
On Tue, May 27, 2008 at 3:42 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote: > [+python-3000] > > On Tue, May 27, 2008 at 12:32 PM, Armin Ronacher > <[EMAIL PROTECTED]> wrote: >> Basically *the* problematic situation with iterable strings is something like >> a `flatten` function that flattens out

Re: [Python-Dev] Iterable String Redux (aka String ABC)

2008-05-27 Thread Antoine Pitrou
(just my 2 eurocents) Guido van Rossum python.org> writes: > > I'm not against this, but so far I've not been able to come up with a > good set of methods to endow the String ABC with. If we stay minimalistic we could consider that the three basic operations that define a string are: - testing

Re: [Python-Dev] Iterable String Redux (aka String ABC)

2008-05-27 Thread Georg Brandl
Antoine Pitrou schrieb: (just my 2 eurocents) Guido van Rossum python.org> writes: I'm not against this, but so far I've not been able to come up with a good set of methods to endow the String ABC with. If we stay minimalistic we could consider that the three basic operations that define a

Re: [Python-Dev] Iterable String Redux (aka String ABC)

2008-05-27 Thread Antoine Pitrou
Georg Brandl gmx.net> writes: > I'd argue that "find" is more primitive than "split" -- split is intuitively > implemented using find and slicing, but implementing find using split and > len is unintuitive. (Of course, "index" can be used instead of "find".) I meant semantically primitive. I thi

Re: [Python-Dev] Iterable String Redux (aka String ABC)

2008-05-27 Thread Armin Ronacher
Hi, Georg Brandl gmx.net> writes: > I'd argue that "find" is more primitive than "split" -- split is intuitively > implemented using find and slicing, but implementing find using split and > len is unintuitive. (Of course, "index" can be used instead of "find".) It surely is, but it would proba

Re: [Python-Dev] Iterable String Redux (aka String ABC)

2008-05-27 Thread Georg Brandl
Antoine Pitrou schrieb: Georg Brandl gmx.net> writes: I'd argue that "find" is more primitive than "split" -- split is intuitively implemented using find and slicing, but implementing find using split and len is unintuitive. (Of course, "index" can be used instead of "find".) I meant semanti

Re: [Python-Dev] Iterable String Redux (aka String ABC)

2008-05-27 Thread Antoine Pitrou
Georg Brandl gmx.net> writes: > > It does, but I don't see how it contradicts my proposition. find() takes a > substring as well. Well, I'm not sure what your proposal was :-) Did you mean to keep split() out of the String interface, or to provide a default implementation of it based on find() a

Re: [Python-Dev] Iterable String Redux (aka String ABC)

2008-05-27 Thread Georg Brandl
Antoine Pitrou schrieb: Georg Brandl gmx.net> writes: It does, but I don't see how it contradicts my proposition. find() takes a substring as well. Well, I'm not sure what your proposal was :-) Did you mean to keep split() out of the String interface, or to provide a default implementation o

Re: [Python-Dev] Iterable String Redux (aka String ABC)

2008-05-27 Thread Antoine Pitrou
Georg Brandl gmx.net> writes: > You wrote: > > > If we stay minimalistic we could consider that the three basic operations that > > define a string are: > > - testing for substring containment > > - splitting on a substring into a list of substrings > > - slicing in order to extract a substr

Re: [Python-Dev] Iterable String Redux (aka String ABC)

2008-05-27 Thread Raymond Hettinger
[Armin Ronacher] Basically *the* problematic situation with iterable strings is something like a `flatten` function that flattens out every iterable object except of strings. Stated more generally: The problematic situation is that flatten() implementations typically need some way to decide wh

Re: [Python-Dev] [Python-3000] Iterable String Redux (aka String ABC)

2008-05-27 Thread Jim Jewett
On 5/27/08, Benji York wrote: > Guido van Rossum wrote: > > Armin Ronacher wrote: > >> Basically *the* problematic situation with iterable strings is something > >> like > >> a `flatten` function that flattens out every iterable object except of > strings. > > I'm not against this, but so far

Re: [Python-Dev] [Python-3000] Iterable String Redux (aka StringABC)

2008-05-27 Thread Raymond Hettinger
"Jim Jewett" It isn't really stringiness that matters, it is that you have to terminate even though you still have an iterable container. Well said. Guido had at least a start in Searchable, back when ABC were still in the sandbox: Have to disagree here. An object cannot know in general w

Re: [Python-Dev] Iterable String Redux (aka String ABC)

2008-05-27 Thread Terry Reedy
"Armin Ronacher" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Basically *the* problematic situation with iterable strings is something like | a `flatten` function that flattens out every iterable object except of strings. In most real cases I can imagine, this is way too broad

Re: [Python-Dev] Iterable String Redux (aka String ABC)

2008-05-27 Thread Steven D'Aprano
(If you receive this twice, please excuse the duplicate email. User-error on my part, sorry.) On Wed, 28 May 2008 08:23:38 am Raymond Hettinger wrote: > A flatten() implementation doesn't really care about whether > an input is a string which supports all the string-like methods > such as capita

Re: [Python-Dev] Iterable String Redux (aka String ABC)

2008-05-27 Thread Raymond Hettinger
Steven D'Aprano" <[EMAIL PROTECTED]> If built-in objects grew an __atomic__ attribute, you could simplify the atomic() function greatly: I may not have been clear enough in my previous post. Atomicity is not an intrinsic property of an object or class. How could you know in advance what various

Re: [Python-Dev] Issue 643841: Including a new-style proxy base class in 2.6/3.0

2008-05-27 Thread Greg Ewing
Armin Ronacher wrote: I'm currently not providing any __r*__ methods as I was too lazy to test on each call if the method that is proxied is providing an __rsomething__ or not, and if not come up with an ad-hoc implementation by calling __something__ and reversing the arguments passed. I don't

Re: [Python-Dev] Issue 643841: Including a new-style proxy base class in 2.6/3.0

2008-05-27 Thread Greg Ewing
Nick Coghlan wrote: else: # Returned a different object, make a new proxy result = type(self)(result) You might want to check that the result has the same type as the proxied object before doing that. -- Greg ___ Python-Dev maili

Re: [Python-Dev] Iterable String Redux (aka String ABC)

2008-05-27 Thread Terry Reedy
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Just throwing a suggestion out there... def atomic(obj, _atomic=(basestring,)): try: return bool(obj.__atomic__) except AttributeError: if isinstance(obj, _atomic): return True

Re: [Python-Dev] Why is type_modified() in typeobject.c not a public function?

2008-05-27 Thread Stefan Behnel
Hi, Guido van Rossum wrote: > On Tue, May 27, 2008 at 9:47 AM, Stefan Behnel <[EMAIL PROTECTED]> wrote: >> Could this function get a public interface? I do not think Cython is the only >> case where C code wants to modify a type after its creation, and copying the >> code over seems like a hack to

[Python-Dev] Deprecated Cookie classes in Py3k

2008-05-27 Thread techtonik
I've noticed that some classes in Cookies module (namely SerialCookie and SmartCookie) deprecated since 2.3 still present in Python3000 documentation. http://docs.python.org/dev/3.0/library/http.cookies.html Is it because ... ?: 1. Docs are not synchronized with API 2. Classes are not removed yet