On 4/10/2010 8:32 AM, Stefan Behnel wrote:
Steven D'Aprano, 08.04.2010 03:41:
On Wed, 07 Apr 2010 10:55:10 -0700, Raymond Hettinger wrote:
If the two collections have unequal sizes, then both ways immediately
return unequal.
Perhaps I'm misinterpreting what you are saying, but I can't conf
Steven D'Aprano, 08.04.2010 03:41:
On Wed, 07 Apr 2010 10:55:10 -0700, Raymond Hettinger wrote:
[Gustavo Nare]
In other words: The more different elements two collections have, the
faster it is to compare them as sets. And as a consequence, the more
equivalent elements two collections have, th
> > I don't know if it's a good "fix" anyway. If you subclass an internal
> > type, you can certainly supply your own rich comparison methods, which
> > would (IMO) put the CPU computation burden where it belongs if you
> > decide to do something goofy like subclass a list and then override
> > __
On Apr 9, 1:07 pm, "Gabriel Genellina" wrote:
> En Thu, 08 Apr 2010 21:02:23 -0300, Patrick Maupin
> escribió:
>
> > On Apr 8, 6:35 pm, "Gabriel Genellina" wrote:
>
> >> The CPython source contains lots of shortcuts like that. Perhaps the
> >> checks should be stricter in some cases, but I i
En Thu, 08 Apr 2010 21:02:23 -0300, Patrick Maupin
escribió:
On Apr 8, 6:35 pm, "Gabriel Genellina" wrote:
The CPython source contains lots of shortcuts like that. Perhaps the
checks should be stricter in some cases, but I imagine it's not so easy
to fix: lots of code was written in the p
On Apr 8, 6:35 pm, "Gabriel Genellina" wrote:
> The CPython source contains lots of shortcuts like that. Perhaps the
> checks should be stricter in some cases, but I imagine it's not so easy to
> fix: lots of code was written in the pre-2.2 era, assuming that internal
> types were not subcl
En Thu, 08 Apr 2010 04:07:53 -0300, Steven D'Aprano
escribió:
On Wed, 07 Apr 2010 20:14:23 -0700, Raymond Hettinger wrote:
[Raymond Hettinger]
> If the two collections have unequal sizes, then both ways immediately
> return unequal.
[Steven D'Aprano]
Perhaps I'm misinterpreting what you
[Steven D'Aprano]
> So what happens in my example with a subclass that (falsely) reports a
> different length even when the lists are the same?
>
> I can guess that perhaps Py_SIZE does not call the subclass __len__
> method, and therefore is not fooled by it lying. Is that the case?
Yes. Py_SIZE
On 4/8/2010 3:07 AM, Steven D'Aprano wrote:
On Wed, 07 Apr 2010 20:14:23 -0700, Raymond Hettinger wrote:
[Raymond Hettinger]
If the two collections have unequal sizes, then both ways immediately
return unequal.
[Steven D'Aprano]
Perhaps I'm misinterpreting what you are saying, but I can't c
On Wed, 07 Apr 2010 20:14:23 -0700, Raymond Hettinger wrote:
> [Raymond Hettinger]
>> > If the two collections have unequal sizes, then both ways immediately
>> > return unequal.
>
> [Steven D'Aprano]
>> Perhaps I'm misinterpreting what you are saying, but I can't confirm
>> that behaviour, at le
[Raymond Hettinger]
> > If the two collections have unequal sizes, then both ways immediately
> > return unequal.
[Steven D'Aprano]
> Perhaps I'm misinterpreting what you are saying, but I can't confirm that
> behaviour, at least not for subclasses of list:
For doubters, see list_richcompare() in
On Apr 7, 8:41 pm, Steven D'Aprano
wrote:
> On Wed, 07 Apr 2010 10:55:10 -0700, Raymond Hettinger wrote:
> > [Gustavo Nare]
> >> In other words: The more different elements two collections have, the
> >> faster it is to compare them as sets. And as a consequence, the more
> >> equivalent elements
On Wed, 07 Apr 2010 10:55:10 -0700, Raymond Hettinger wrote:
> [Gustavo Nare]
>> In other words: The more different elements two collections have, the
>> faster it is to compare them as sets. And as a consequence, the more
>> equivalent elements two collections have, the faster it is to compare
>>
[Gustavo Nare]
> In other words: The more different elements two collections have, the
> faster it is to compare them as sets. And as a consequence, the more
> equivalent elements two collections have, the faster it is to compare
> them as lists.
>
> Is this correct?
If two collections are equal,
On 04/07/10 04:11, Gustavo Narea wrote:
> Hello!
>
> Could you please confirm whether my understanding of equality
> operations in sets and lists is correct? This is how I think things
> work, partially based on experimentation and the online documentation
> for Python:
>
> When you compare two l
On Tue, Apr 6, 2010 at 2:11 PM, Gustavo Narea wrote:
> Hello!
>
> Could you please confirm whether my understanding of equality
> operations in sets and lists is correct? This is how I think things
> work, partially based on experimentation and the online documentation
> for Python:
>
> When you c
:slaps forehead:
good catch.
On Tue, Apr 6, 2010 at 5:18 PM, Gustavo Narea wrote:
> On Apr 6, 7:28 pm, Chris Colbert wrote:
>> the proof is in the pudding:
>>
>> In [1]: a = range(1)
>>
>> In [2]: s = set(a)
>>
>> In [3]: s2 = set(a)
>>
>> In [5]: b = range(1)
>>
>> In [6]: a == b
>> Ou
On Apr 6, 7:28 pm, Chris Colbert wrote:
> the proof is in the pudding:
>
> In [1]: a = range(1)
>
> In [2]: s = set(a)
>
> In [3]: s2 = set(a)
>
> In [5]: b = range(1)
>
> In [6]: a == b
> Out[6]: True
>
> In [7]: s == s2
> Out[7]: True
>
> In [8]: %timeit a == b
> 1000 loops, best of 3: 2
the proof is in the pudding:
In [1]: a = range(1)
In [2]: s = set(a)
In [3]: s2 = set(a)
In [5]: b = range(1)
In [6]: a == b
Out[6]: True
In [7]: s == s2
Out[7]: True
In [8]: %timeit a == b
1000 loops, best of 3: 204 us per loop
In [9]: %timeit s == s2
1 loops, best of 3: 124 us
19 matches
Mail list logo