On Thu, 23 Oct 2008 05:03:26 -0700, Jani Tiainen wrote:
> But in my case running that loop takes about 10 minutes. What I am doing
> wrong?
Others have already suggested you have a O(N**2) algorithm. Here's an
excellent article that explains more about them:
http://www.joelonsoftware.com/articl
Hrvoje Niksic:
> You're right. The OP states he implements __eq__, so he also needs a
> matching __hash__, such as:
>
> def __hash__(self, other):
> return (hash(self.xcoord) ^ hash(self.ycoord) ^
> hash(self.streetname) ^ hash(self.streetno))
The hash function by Otte
[EMAIL PROTECTED] writes:
>> internal = set(list_internal)
> ...
>
> To do that the original poster may have to define a __hash__ and
> __eq__ methods in his/her class.
You're right. The OP states he implements __eq__, so he also needs a
matching __hash__, such as:
def __hash__(self, other)
On 23 loka, 15:24, Peter Otten <[EMAIL PROTECTED]> wrote:
> Jani Tiainen wrote:
> > I have rather simple 'Address' object that contains streetname,
> > number, my own status and x,y coordinates for it. I have two lists
> > both containing approximately 3 addresses.
>
> > I've defined __eq__ met
Jani Tiainen a écrit :
I have rather simple 'Address' object that contains streetname,
number, my own status and x,y coordinates for it. I have two lists
both containing approximately 3 addresses.
I've defined __eq__ method in my class like this:
def __eq__(self, other):
return
On Thu, Oct 23, 2008 at 2:03 PM, Jani Tiainen <[EMAIL PROTECTED]> wrote:
> I have rather simple 'Address' object that contains streetname,
> number, my own status and x,y coordinates for it. I have two lists
> both containing approximately 3 addresses.
>
> I've defined __eq__ method in my clas
Hrvoje Niksic:
> internal = set(list_internal)
...
To do that the original poster may have to define a __hash__ and
__eq__ methods in his/her class.
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list
Jani Tiainen wrote:
> I have rather simple 'Address' object that contains streetname,
> number, my own status and x,y coordinates for it. I have two lists
> both containing approximately 3 addresses.
>
> I've defined __eq__ method in my class like this:
>
> def __eq__(self, other):
>
Jani Tiainen <[EMAIL PROTECTED]> writes:
> for addr in list_external:
> if addr not in list_internal:
> addr.status = 1 # New address
>
> But in my case running that loop takes about 10 minutes. What I am
> doing wrong?
The nested loop takes time proportional to the product of the num