Re: [Python-Dev] Why not using the hash when comparing strings?

2012-10-19 Thread Duncan Booth
Hrvoje Niksic wrote: > On 10/19/2012 03:22 AM, Benjamin Peterson wrote: >> It would be interesting to see how common it is for strings which have >> their hash computed to be compared. > > Since all identifier-like strings mentioned in Python are interned, and > therefore have had their hash co

Re: [Python-Dev] PEP 383 (again)

2009-04-28 Thread Duncan Booth
Hrvoje Niksic wrote: > Assume a UTF-8 locale. A file named b'\xff', being an invalid UTF-8 > sequence, will be converted to the half-surrogate '\udcff'. However, > a file named b'\xed\xb3\xbf', a valid[1] UTF-8 sequence, will also be > converted to '\udcff'. Those are quite different POSIX p

Re: [Python-Dev] slightly inconsistent set/list pop behaviour

2009-04-08 Thread Duncan Booth
Andrea Griffini wrote: > On Wed, Apr 8, 2009 at 12:57 PM, Jack diederich > wrote: >> You wrote a program to find the two smallest ints that would have a >> hash collision in the CPython set implementation?  I'm impressed. >>  And by impressed I mean frightened. > > ? > > print set([0,8]).pop(

Re: [Python-Dev] Ruby-style Blocks in Python [Pseudo-PEP]

2009-03-08 Thread Duncan Booth
tav wrote: > I explain in detail in this blog article: > > http://tav.espians.com/ruby-style-blocks-in-python.html > "This is also possible in Python but at the needless cost of naming and defining a function first" The cost of defining the function first is probably much less than the cos

Re: [Python-Dev] repeated keyword arguments

2008-07-02 Thread Duncan Booth
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote: > It would be nice to be able to do this: > > defaults = dict(a=5, b=7) > f(**defaults, a=8) # override the value of a in defaults > > but unfortunately that gives a syntax error. Reversing the order would > override the wrong value. So as Python ex

Re: [Python-Dev] Adding start to enumerate()

2008-05-13 Thread Duncan Booth
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote: > On Mon, 12 May 2008 08:20:51 am Georg Brandl wrote: >> I believe the following is a common use-case for enumerate() >> (at least, I've used it quite some times): >> >> for lineno, line in enumerate(fileobject): >> ... >> >> For this, it would be

Re: [Python-Dev] Complexity documentation request

2008-03-13 Thread Duncan Booth
Dimitrios Apostolou <[EMAIL PROTECTED]> wrote: > On another note which sorting algorithm is python using? Perhaps we can > add this as a footnote. I always thought it was quicksort, with a worst > case of O(n^2). See http://svn.python.org/projects/python/trunk/Objects/listsort.txt

Re: [Python-Dev] Declaring setters with getters

2007-11-02 Thread Duncan Booth
Greg Ewing <[EMAIL PROTECTED]> wrote: > Fred Drake wrote: >>@property >>def attribute(self): >>return 42 >> >>@property.set >>def attribute(self, value): >>self._ignored = value > > Hmmm... if you were allowed general lvalues as the target

Re: [Python-Dev] Declaring setters with getters

2007-11-01 Thread Duncan Booth
"Steven Bethard" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > On 10/31/07, Fred Drake <[EMAIL PROTECTED]> wrote: >> If I had to choose built-in names, though, I'd prefer "property", >> "propset", "propdel". Another possibility that seems reasonable >> (perhaps a bit better) would be: >>

Re: [Python-Dev] generators and with

2007-05-13 Thread Duncan Booth
"tomer filiba" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > why not add __enter__ and __exit__ to generator objects? > it's really a trivial addition: __enter__ returns self, __exit__ calls > close(). > it would be used to ensure close() is called when the generator is > disposed, inste

Re: [Python-Dev] whitespace normalization

2007-04-25 Thread Duncan Booth
"Neal Norwitz" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > I just checked in a whitespace normalization change that was way too > big. Should this task be automated? IMHO, changing whitespace retrospectively in a version control system is a bad idea. How much overhead would it be t

Re: [Python-Dev] __del__ unexpectedly being called twice

2006-08-18 Thread Duncan Booth
"Terry Reedy" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > > "Duncan Booth" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> There's a thread on comp.lang.python at the moment under the subject >> "It

[Python-Dev] __del__ unexpectedly being called twice

2006-08-18 Thread Duncan Booth
There's a thread on comp.lang.python at the moment under the subject "It is __del__ calling twice for some instances?" which seems to show that when releasing a long chain of old-style classes every 50th approximately has its finaliser called twice. I've verified that this happens on both Python

Re: [Python-Dev] segmentation fault in Python 2.5b3 (trunk:51066)

2006-08-03 Thread Duncan Booth
Thomas Heller <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: >> /* if no docstring given and the getter has one, use that one */ >> if ((doc == NULL || doc == Py_None) && get != NULL && >> PyObject_HasAttrString(get, "__doc__")) { >> if (!(get_doc = PyObject_Ge

Re: [Python-Dev] reference leaks, __del__, and annotations

2006-03-31 Thread Duncan Booth
"Jim Jewett" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > As a strawman proposal: > > deletes = [(obj.__del__.cycle, obj) for obj in cycle > if hasattr(obj, "__del__") and > hasattr(obj.__del__, "cycle")] > deletes.sort() > for (cycle, obj) in dele

Re: [Python-Dev] The decorator(s) module

2006-02-11 Thread Duncan Booth
Georg Brandl <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Unfortunately, a @property decorator is impossible... > It all depends what you want (and whether you want the implementation to be portable to other Python implementations). Here's one possible but not exactly portable exampl

Re: [Python-Dev] Path PEP and the division operator

2006-02-05 Thread Duncan Booth
Nick Coghlan <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Duncan Booth wrote: >> I'm not convinced by the rationale given why atime,ctime,mtime and >> size are methods rather than properties but I do find this PEP much >> more agreeable than the last ti

Re: [Python-Dev] Path PEP and the division operator

2006-02-04 Thread Duncan Booth
BJörn Lindqvist <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > On 2/4/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: >> I won't even look at the PEP as long as it uses / or // (or any other >> operator) for concatenation. > > That's good, because it doesn't. :) > http://www.python.org/p

Re: [Python-Dev] properties and block statement

2005-10-19 Thread Duncan Booth
Stefan Rank <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > I think there is no need for a special @syntax for this to work. > > I suppose it would be possible to allow a trailing block after any > function invocation, with the effect of creating a new namespace that > gets treated as co

Re: [Python-Dev] bug in urlparse

2005-09-06 Thread Duncan Booth
[EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: > According to RFC 2396[1] section 5.2: > > g) If the resulting buffer string still begins with one or more > complete path segments of "..", then the reference is > considered to be in error. Implementations may handle t

Re: [Python-Dev] Re: anonymous blocks

2005-04-27 Thread Duncan Booth
Jim Fulton <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: >> No, the return sets a flag and raises StopIteration which should make >> the iterator also raise StopIteration at which point the real return >> happens. > > Only if exc is not None > > The only return in the pseudocode is insid

Re: [Python-Dev] Re: anonymous blocks

2005-04-27 Thread Duncan Booth
Jim Fulton <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Guido van Rossum wrote: >> I've written a PEP about this topic. It's PEP 340: Anonymous Block >> Statements (http://python.org/peps/pep-0340.html). >> > Some observations: > > 1. It looks to me like a bare return or a return with