Re: [Python-Dev] Retrieve an arbitrary element from a set without removing it

2009-10-24 Thread Nick Coghlan
Ben Finney wrote: > Which then raises the question “what part of the set does it get?”, > which the function signature does nothing to answer. I'm proposing that > a no-parameters ‘set.get’ is needlessly confusing to think about. The fact that set.get() is just set.pop() without removing the resul

Re: [Python-Dev] Retrieve an arbitrary element from a set without removing it

2009-10-24 Thread Martin (gzlist)
On 24/10/2009, Nick Coghlan wrote: > Ben Finney wrote: >> Which then raises the question “what part of the set does it get?”, >> which the function signature does nothing to answer. I'm proposing that >> a no-parameters ‘set.get’ is needlessly confusing to think about. > > The fact that set.get()

Re: [Python-Dev] First shot at some_set.get()

2009-10-24 Thread Steven D'Aprano
On Sat, 24 Oct 2009 05:04:33 pm Stephen J. Turnbull wrote: > Steven D'Aprano writes: > >  > I'm not being tongue-in-cheek or sarcastic. My question was > serious -- > if there is a moratorium, is there any reason to bother > submitting > patches for functional changes to built-ins? > > Yes.  Python

Re: [Python-Dev] Retrieve an arbitrary element from a set without removing it

2009-10-24 Thread Willi Richert
Hi, I agree. But, here are the pros/cons collected from the recent list repsonses: Pro: - more readable - newbies will encounter one of the fastest solution (.get()) before trying slower "first solutions" like (iter(set).next()) Cons: - no name consensus. get() getany() arbitrary() ? - BDFL

Re: [Python-Dev] Retrieve an arbitrary element from a set without removing it

2009-10-24 Thread Steven D'Aprano
On Sat, 24 Oct 2009 08:12:26 pm Martin (gzlist) wrote: > On 24/10/2009, Nick Coghlan wrote: > > Ben Finney wrote: > >> Which then raises the question “what part of the set does it > >> get?”, which the function signature does nothing to answer. I'm > >> proposing that a no-parameters ‘set.get’ is

Re: [Python-Dev] First shot at some_set.get()

2009-10-24 Thread Martin v. Löwis
> I'm not being tongue-in-cheek or sarcastic. My question was serious -- > if there is a moratorium, is there any reason to bother submitting > patches for functional changes to built-ins? A lot can change between > now and 2013, and I for one wouldn't bother making a patch that I knew > wouldn

Re: [Python-Dev] Retrieve an arbitrary element from a set without removing it

2009-10-24 Thread Willi Richert
Hi, someone on this list mentioned that much of the s.get() time is spend on the name lookup for get(). That is indeed the case: === from timeit import * stats = ["for i in xrange(1000): iter(s).next() ", "for i in xrange(1000): \n\tfor x in s: \n\t\tbreak",

Re: [Python-Dev] Retrieve an arbitrary element from a set without removing it

2009-10-24 Thread Alexander Belopolsky
On Fri, Oct 23, 2009 at 6:46 PM, Steven D'Aprano wrote: > On Sat, 24 Oct 2009 06:04:12 am Terry Reedy wrote: .. >> fwiw, I think the use case for this is sufficiently rare that it does >> not need a separate method just for this purpose. > > > And yet it keeps coming up, again and again... obvious

Re: [Python-Dev] First shot at some_set.get()

2009-10-24 Thread geremy condra
On Sat, Oct 24, 2009 at 11:28 AM, "Martin v. Löwis" wrote: >> I'm not being tongue-in-cheek or sarcastic. My question was serious -- >> if there is a moratorium, is there any reason to bother submitting >> patches for functional changes to built-ins? A lot can change between >> now and 2013, and I

Re: [Python-Dev] Retrieve an arbitrary element from a set without removing it

2009-10-24 Thread Guido van Rossum
On Sat, Oct 24, 2009 at 10:34 AM, Alexander Belopolsky wrote: > To me, however, a set seems to be a container that is a specialization > of a dict with values and keys being the same. That's absurd; the mapping provides nothing useful. -- --Guido van Rossum PS. My elbow needs a couple more wee

Re: [Python-Dev] First shot at some_set.get()

2009-10-24 Thread Guido van Rossum
On Sat, Oct 24, 2009 at 10:55 AM, geremy condra wrote: > My understanding is that the moratorium would preclude changes to > the builtins. Is that not the case here? It is as yet undecided. -- --Guido van Rossum PS. My elbow needs a couple more weeks of rest. Limiting myself to ultra-short ema

[Python-Dev] Clean up Python/thread_*.h ?

2009-10-24 Thread Antoine Pitrou
Hello, I am wondering which of the files in Python/thread_*.h are really necessary today. Looking at these files, I think most of them could perhaps be removed in py3k. I've identified three categories of potentially removable files: * The unused file: thread_wince.h Windows CE has actually bee

Re: [Python-Dev] interning

2009-10-24 Thread Antoine Pitrou
Alexander Belopolsky gmail.com> writes: > > AB> I disagree with Martin. I think interning is a set > AB> operation and it is unfortunate that set API does not > AB> support it directly. > > ML> I disagree with Alexander's last remark in several respects: [...] > ML> The operation "give me the me

Re: [Python-Dev] Clean up Python/thread_*.h ?

2009-10-24 Thread Christian Heimes
Antoine Pitrou wrote: > * The unused file: thread_wince.h > > Windows CE has actually been using thread_nt.h since January 2009 (see > http://bugs.python.org/issue4893 ). thread_wince.h is still there, but it's > unused and grep brings no instance of it being mentioned anywhere in the > source >

[Python-Dev] updated PEP 389: argparse

2009-10-24 Thread Steven Bethard
Sorry for the delay, but I've finally updated PEP 389, the argparse PEP, based on all the feedback from python-dev. The full PEP is below, but in short, the important changes are: * The getopt module will *not* be deprecated. * In Python 2, the -3 flag will cause deprecation warnings to be issued

Re: [Python-Dev] Retrieve an arbitrary element from a set without removing it

2009-10-24 Thread Terry Reedy
Steven D'Aprano wrote: On Sat, 24 Oct 2009 08:12:26 pm Martin (gzlist) wrote: There's a different proposed meaning for `set.get` that's been discussed on python-dev before: For that case, I think the OP was mistaken mistak

Re: [Python-Dev] Clean up Python/thread_*.h ?

2009-10-24 Thread Martin v. Löwis
> Making a decision and removing the files considered unnecessary would clarify > what platforms still are/should be supported. I think any such removal should go through the PEP 11 process. Put a #error into the files for 3.2, and a removal notice into the PEP, then remove them in 3.3. As for OS

Re: [Python-Dev] Retrieve an arbitrary element from a set without removing it

2009-10-24 Thread Terry Reedy
Guido van Rossum wrote: On Sat, Oct 24, 2009 at 10:34 AM, Alexander Belopolsky wrote: To me, however, a set seems to be a container that is a specialization of a dict with values and keys being the same. That's absurd; the mapping provides nothing useful. Given Alexander's premise, I agree

Re: [Python-Dev] Retrieve an arbitrary element from a set without removing it

2009-10-24 Thread Terry Reedy
Alexander Belopolsky wrote: On Fri, Oct 23, 2009 at 6:46 PM, Steven D'Aprano wrote: On Sat, 24 Oct 2009 06:04:12 am Terry Reedy wrote: .. fwiw, I think the use case for this is sufficiently rare that it does not need a separate method just for this purpose. And yet it keeps coming up, again

Re: [Python-Dev] Clean up Python/thread_*.h ?

2009-10-24 Thread Antoine Pitrou
Martin v. Löwis v.loewis.de> writes: > > > Making a decision and removing the files considered unnecessary would > > clarify > > what platforms still are/should be supported. > > I think any such removal should go through the PEP 11 process. Put a > #error into the files for 3.2, and a removal

Re: [Python-Dev] Retrieve an arbitrary element from a set without removing it

2009-10-24 Thread Adam Olsen
On Fri, Oct 23, 2009 at 11:04, Vitor Bosshard wrote: > I see this as being useful for frozensets as well, where you can't get > an arbitrary element easily due to the obvious lack of .pop(). I ran > into this recently, when I had a frozenset that I knew had 1 element > (it was the difference betwe

Re: [Python-Dev] updated PEP 389: argparse

2009-10-24 Thread Ben Finney
Steven Bethard writes: > Discussion: sys.err and sys.exit > > There were some concerns that argparse by default always writes to > ``sys.err`` […] Unless, I'm missing something, this should replace ‘sys.err’ with ‘sys.stderr’ throughout. -- \ “Pinky, a

Re: [Python-Dev] updated PEP 389: argparse

2009-10-24 Thread Steven Bethard
On Sat, Oct 24, 2009 at 4:34 PM, Ben Finney wrote: > Steven Bethard writes: > >> Discussion: sys.err and sys.exit >> >> There were some concerns that argparse by default always writes to >> ``sys.err`` > […] > > Unless, I'm missing something, this should replace ‘

Re: [Python-Dev] Retrieve an arbitrary element from a set without removing it

2009-10-24 Thread John Arbash Meinel
Adam Olsen wrote: > On Fri, Oct 23, 2009 at 11:04, Vitor Bosshard wrote: >> I see this as being useful for frozensets as well, where you can't get >> an arbitrary element easily due to the obvious lack of .pop(). I ran >> into this recently, when I had a frozenset that I knew had 1 element >> (it

Re: [Python-Dev] Retrieve an arbitrary element from a set without removing it

2009-10-24 Thread Alex Martelli
Next(s) would seem good... Alex Sent from my iPhone On Oct 24, 2009, at 6:47 PM, John Arbash Meinel > wrote: Adam Olsen wrote: On Fri, Oct 23, 2009 at 11:04, Vitor Bosshard wrote: I see this as being useful for frozensets as well, where you can't get an arbitrary element easily due to

Re: [Python-Dev] Retrieve an arbitrary element from a set without removing it

2009-10-24 Thread Nick Coghlan
Terry Reedy wrote: >> In this model, a >> get() method, or even a __getitem__ with s[k] is k, is only natural. > > No, if key and value were the same thing, the get method would be > nonesense, as Guido said. But since they are not, since the implict key > is an abstract class, retrieving the rep

Re: [Python-Dev] updated PEP 389: argparse

2009-10-24 Thread Nick Coghlan
Steven Bethard wrote: > Sorry for the delay, but I've finally updated PEP 389, the argparse > PEP, based on all the feedback from python-dev. The full PEP is below, > but in short, the important changes are: > > * The getopt module will *not* be deprecated. > * In Python 2, the -3 flag will cause

Re: [Python-Dev] Retrieve an arbitrary element from a set without removing it

2009-10-24 Thread Terry Reedy
Alex Martelli wrote: Next(s) would seem good... That does not work. It has to be next(iter(s)), and that has been tried and eliminated because it is significantly slower. Interesting. It depends a bit on the speed of tuple unpacking, but presumably that is quite fast. On my system it is pre