[Python-Dev] Mini-Pep: An Empty String ABC

2008-05-31 Thread Raymond Hettinger
Mini-Pep: An Empty String ABC Target: Py2.6 and Py3.0 Author: Raymond Hettinger Proposal Add a new collections ABC specified as: class String(Sequence): pass Motivation -- Having an ABC for strings allows string look-alike classes to declare themselves as sequence

[Python-Dev] Mini-Pep: Simplifying the Integral ABC

2008-05-31 Thread Raymond Hettinger
Target: Py2.6 and Py3.0 Author: Raymond Hettinger Date: May 31, 2008 Motivation -- The principal purpose of an abstract base class is to support multiple implementations of an API; thereby allowing one concrete class to be substitutable for another. This purpose is defeated when useful s

Re: [Python-Dev] C API for gc.enable() and gc.disable()

2008-05-31 Thread Adam Olsen
On Sat, May 31, 2008 at 10:11 PM, Alexandre Vassalotti <[EMAIL PROTECTED]> wrote: > Would anyone mind if I did add a public C API for gc.disable() and > gc.enable()? I would like to use it as an optimization for the pickle > module (I found out that I get a good 2x speedup just by disabling the > G

[Python-Dev] C API for gc.enable() and gc.disable()

2008-05-31 Thread Alexandre Vassalotti
Would anyone mind if I did add a public C API for gc.disable() and gc.enable()? I would like to use it as an optimization for the pickle module (I found out that I get a good 2x speedup just by disabling the GC while loading large pickles). Of course, I could simply import the gc module and call th

Re: [Python-Dev] Alternative to more ABCs [was:] Iterable String Redux (aka String ABC)

2008-05-31 Thread Guido van Rossum
On Sat, May 31, 2008 at 8:09 PM, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > [Raymond] >>> >>> I propose the following empty abstract classes: String, Datetime, >>> Deque, >>> and Socket. > > [GvR] >> >> Sounds like a mini-PEP is in place. It should focus on the code to >> actually define th

Re: [Python-Dev] Alternative to more ABCs [was:] Iterable String Redux (aka String ABC)

2008-05-31 Thread Raymond Hettinger
[Raymond] I propose the following empty abstract classes: String, Datetime, Deque, and Socket. [GvR] Sounds like a mini-PEP is in place. It should focus on the code to actually define these and the intended ways to use them. Okay, will run a Google code search to see if real code exists

Re: [Python-Dev] Alternative to more ABCs [was:] Iterable String Redux (aka String ABC)

2008-05-31 Thread Guido van Rossum
On Sat, May 31, 2008 at 6:41 PM, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > From: "Guido van Rossum" <[EMAIL PROTECTED]> >> I'm willing to meet you halfway. I really don't want isinstance(x, >> str) to return True for something that doesn't inherit from the >> concrete str type; this is bound t

Re: [Python-Dev] PEP 371 Discussion (pyProcessing Module)

2008-05-31 Thread Mark Hammond
> 2008/5/30 Farshid Lashkari <[EMAIL PROTECTED]>: > > I'm not sure if there will be any side affects to modifying > > sys.executable though. Should this be the official way of supporting > > embedded interpreters or should there be a > > multiprocessing.setExecutable() method? > > +1 for setExecut

Re: [Python-Dev] Alternative to more ABCs [was:] Iterable String Redux (aka String ABC)

2008-05-31 Thread Raymond Hettinger
From: "Guido van Rossum" <[EMAIL PROTECTED]> I'm willing to meet you halfway. I really don't want isinstance(x, str) to return True for something that doesn't inherit from the concrete str type; this is bound to lead to too much confusion and breakage. Probably true. It was an attractive id

Re: [Python-Dev] Alternative to more ABCs [was:] Iterable String Redux (aka String ABC)

2008-05-31 Thread Nick Coghlan
Raymond Hettinger wrote: If we don't do this, then String won't be the last request. People will want Datetime for example. Pretty much any concrete type could have a look-a-like that wanted its own ABC and for all client code to switch from testing concrete types. If I remember rightly, th

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

2008-05-31 Thread Antoine Pitrou
Simon Cross gmail.com> writes: > My tests show that the old-style % formatting is much faster when the > final string is 20 characters or less: > > $ ./python -m timeit "'|||...%s' % '12'" > 1000 loops, best of 3: 0.0764 usec per loop You are the victim of a constant-folding opt

Re: [Python-Dev] PEP 371 Discussion (pyProcessing Module)

2008-05-31 Thread r.m.oudkerk
On 31/05/2008, Paul Moore <[EMAIL PROTECTED]> wrote: > 2008/5/30 Farshid Lashkari <[EMAIL PROTECTED]>: >> I'm not sure if there will be any side affects to modifying >> sys.executable though. Should this be the official way of supporting >> embedded interpreters or should there be a >> multiprocess

Re: [Python-Dev] Alternative to more ABCs [was:] Iterable String Redux (aka String ABC)

2008-05-31 Thread Guido van Rossum
I'm willing to meet you halfway. I really don't want isinstance(x, str) to return True for something that doesn't inherit from the concrete str type; this is bound to lead to too much confusion and breakage. But I'm fine with a String ABC (or any other ABC, e.g. Atomic?) that doesn't define any me

Re: [Python-Dev] [Python-3000] Finishing up PEP 3108

2008-05-31 Thread Mark Dickinson
On Sat, May 31, 2008 at 11:33 AM, Georg Brandl <[EMAIL PROTECTED]> wrote: > > Now that the docs are reST, the source is almost pretty enough to display > it raw, but I could also imagine a "text" writer that removes the more > obscure markup to present a casual-reader-friendly text version. > > Th

Re: [Python-Dev] Finishing up PEP 3108

2008-05-31 Thread Steve Holden
Georg Brandl wrote: Brett Cannon schrieb: Issue 2873 - htmllib is slated to go, but pydoc still uses it. Then again, pydoc is busted thanks to the new doc format. I will try to handle this in the coming week. Fred had the interesting suggestion of removing pydoc in Py3K based on the thinki

[Python-Dev] Alternative to more ABCs [was:] Iterable String Redux (aka String ABC)

2008-05-31 Thread Raymond Hettinger
ISTM, the whole reason people are asking for a String ABC is so you can write isinstance(obj, String) and allow registered string-like objects to be accepted. The downside is that everytime you want this for a concrete class or type, it is necessary to write a whole new ABC listing all of the r

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

2008-05-31 Thread Georg Brandl
Steven D'Aprano schrieb: but also does it provide a very cool way to get custom sets or lists going with few extra work. Subclassing builtins was always very painful in the past "Always" very painful? class ListWithClear(list): def clear(self): self[:] = self.__class__() Not so

Re: [Python-Dev] PEP 371 Discussion (pyProcessing Module)

2008-05-31 Thread Paul Moore
2008/5/30 Farshid Lashkari <[EMAIL PROTECTED]>: > I'm not sure if there will be any side affects to modifying > sys.executable though. Should this be the official way of supporting > embedded interpreters or should there be a > multiprocessing.setExecutable() method? +1 for setExecutable (I'd pref