[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Adonthell-devel] item equality

From: Kai Sterker
Subject: Re: [Adonthell-devel] item equality
Date: Thu, 30 Jan 2003 14:23:00 +0100

On Wed, 29 Jan 2003 18:26:49 +0100 Kai Sterker wrote:

> So I thought that we could perhaps create a hash of an item's
> properties. That together with the item name should help to check
> whether items are equal or not. The hash could even be saved with the
> item, so it only has to be regenerated when a change is made to an
> item, which shouldn't happen too often.

I have something working. See the attached file.

The benefits of this approach is that it requires no further work from
item creators. As long as an item is derived from and
__setattr__ isn't overwritten, everything happens automatically.

On the downside, it's not as efficient as it could be. For example if I
do something like

    item.SomeVal = 4
    item.SomeOtherVal = 5

then the hash will be recalculated twice. OTOH, I did some timing:
executing the __setattr__ method took between 0.0003 and 0.0010 seconds.
Considering that items wouldn't change that often, that should be okay.

So with that code in place, I'll do some inventory coding, and try to
get the examples from my earlier mail about item actions working. Expect
some results within the next few days.


Description: Binary data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]