Bugs item #1117757, was opened at 2005-02-07 04:16
Message generated for change (Comment added) made by tim_one
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1117757&group_id=5470
Category: Python Interpreter Core
>Group: Not a Bug
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Andrea Bolzonella (bolzonella)
Assigned to: Nobody/Anonymous (nobody)
Summary: "in" operator bug ?
Initial Comment:
my python :
Python 2.4 (#1, Dec 8 2004, 18:57:30)
[GCC 3.3.3 (SuSE Linux)] on linux
>>class C(object):
>> def __getitem__ (self, name):
>> return 1
>> c =C()
>> 'a' in c
here python never returns and CPU 100%
this version works:
>>class C(object):
>> def __getitem__ (self, name):
>> raise StopIteration
>> c =C()
>> 'a' in c
False
----------------------------------------------------------------------
>Comment By: Tim Peters (tim_one)
Date: 2005-02-07 09:56
Message:
Logged In: YES
user_id=31435
Not a bug. See the docs, or ask on comp.lang.python, for
how __getitem__ works. Your original C is a class such that c
[i] == 1 for any instance c and any subscript i. So "1 in c"
will return True quickly, but nothing else can succeed. Add
if name % 100000 == 0:
print 'getting', name
at the start of your original __getitem__ for a clue.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1117757&group_id=5470
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com