On 20 juil, 07:17, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Sat, 19 Jul 2008 13:13:40 -0700, nicolas.pourcelot wrote:
> > On 18 juil, 17:52, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> >> On Fri, 18 Jul 2008 07:39:38 -0700, nicolas.pourcelot wrote:
> >> > So, I use somethi
On 20 juil, 23:18, John Machin <[EMAIL PROTECTED]> wrote:
> On Jul 21, 4:33 am, [EMAIL PROTECTED] wrote:
>
> > > (1) You are searching through lists to find float objects by identity,
> > > not by value
>
> >
>
> You wrote """
> I used short lists (a list of 20 floats) and the element
> checke
On Jul 21, 4:33 am, [EMAIL PROTECTED] wrote:
> > (1) You are searching through lists to find float objects by identity,
> > not by value
>
>
You wrote """
I used short lists (a list of 20 floats) and the element
checked was not in the list.
(That was the case I usually deals with in my code.)
> (1) You are searching through lists to find float objects by identity,
> not by value
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 19 Jul 2008 13:13:40 -0700, nicolas.pourcelot wrote:
> On 18 juil, 17:52, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>> On Fri, 18 Jul 2008 07:39:38 -0700, nicolas.pourcelot wrote:
>> > So, I use something like this in 'sheet.objects.__setattr__(self,
>> > name, value)':
>> > if t
On Jul 20, 6:13 am, [EMAIL PROTECTED] wrote:
> On 18 juil, 17:52, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>
> > On Fri, 18 Jul 2008 07:39:38 -0700, nicolas.pourcelot wrote:
> > > So, I use something like this in 'sheet.objects.__setattr__(self,
> > > name, value)':
> > > if type(value)
On 18 juil, 17:52, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Fri, 18 Jul 2008 07:39:38 -0700, nicolas.pourcelot wrote:
> > So, I use something like this in 'sheet.objects.__setattr__(self,
> > name, value)':
> > if type(value) == Polygon:
> > for edge in value.edges:
> >
Peter Otten wrote:
So, precisely, you mean that if hash(a) != hash(b), a and b are
considered distinct, and else [ie. if hash(a) == hash(b)], a and b are
the same if and only if a == b ?
Correct for set, dict. For lists etc. the hash doesn't matter:
Since CPython saves strings hashes as pa
[EMAIL PROTECTED] wrote:
>> What is your (concrete) use case, by the way?
>
>
>
> I try to make it simple (there is almost 25000 lines of code...)
> I have a sheet with geometrical objects (points, lines, polygons,
> etc.)
> The sheet have an object manager.
>
> So, to simplify :
>
sheet
On Fri, 18 Jul 2008 07:39:38 -0700, nicolas.pourcelot wrote:
> So, I use something like this in 'sheet.objects.__setattr__(self,
> name, value)':
> if type(value) == Polygon:
> for edge in value.edges:
> if edge is_in sheet.objects.__dict__.itervalues():
> object.__setattr_
> What is your (concrete) use case, by the way?
I try to make it simple (there is almost 25000 lines of code...)
I have a sheet with geometrical objects (points, lines, polygons,
etc.)
The sheet have an object manager.
So, to simplify :
>>> sheet.objects.A = Point(0, 0)
>>> sheet.objects.B = P
Peter Otten:
> PS: Take these numbers with a grain of salt, they vary a lot between runs.
Another possibility :-)
from itertools import imap
id(x) in imap(id, items)
>If you want efficiency you should use a dictionary instead of the list anyway:
I agree, but sometimes you have few items to look
[EMAIL PROTECTED] wrote:
> On 18 juil, 13:13, Peter Otten <[EMAIL PROTECTED]> wrote:
>> [EMAIL PROTECTED] wrote:
>> > In fact, 'any(myobject is element for element in mylist)' is 2 times
>> > slower than using a for loop, and 'id(myobject) in (id(element) for
>> > element in mylist)' is 2.4 times
On 18 juil, 13:13, Peter Otten <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > In fact, 'any(myobject is element for element in mylist)' is 2 times
> > slower than using a for loop, and 'id(myobject) in (id(element) for
> > element in mylist)' is 2.4 times slower.
>
> This is not a meanin
On 18 juil, 12:26, Peter Otten <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > I think something like
> id(myobject) in (id(element) for element in mylist)
> > would also work, also it's not so readable, and maybe not so fast
> > (?)...
>
> > An "is in" operator would be nice...
>
>
[EMAIL PROTECTED] wrote:
> In fact, 'any(myobject is element for element in mylist)' is 2 times
> slower than using a for loop, and 'id(myobject) in (id(element) for
> element in mylist)' is 2.4 times slower.
This is not a meaningful statement unless you at least qualify with the
number of item
[EMAIL PROTECTED] wrote:
> I think something like
id(myobject) in (id(element) for element in mylist)
> would also work, also it's not so readable, and maybe not so fast
> (?)...
>
> An "is in" operator would be nice...
And rarely used. Probably even less than the (also missing)
< in, | in
In fact, 'any(myobject is element for element in mylist)' is 2 times
slower than using a for loop, and 'id(myobject) in (id(element) for
element in mylist)' is 2.4 times slower.
--
http://mail.python.org/mailman/listinfo/python-list
On 18 juil, 11:30, Peter Otten <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > Hi,
>
> > I want to test if an object IS in a list (identity and not equality
> > test).
> > I can if course write something like this :
>
> > test = False
> > myobject = MyCustomClass(*args, **kw)
> > for elem
[EMAIL PROTECTED] wrote:
> Hi,
>
> I want to test if an object IS in a list (identity and not equality
> test).
> I can if course write something like this :
>
> test = False
> myobject = MyCustomClass(*args, **kw)
> for element in mylist:
> if element is myobject:
> test = True
>
Hi,
I want to test if an object IS in a list (identity and not equality
test).
I can if course write something like this :
test = False
myobject = MyCustomClass(*args, **kw)
for element in mylist:
if element is myobject:
test = True
break
and I can even write a isinlist(elt,
21 matches
Mail list logo