[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Adonthell-devel] Speeding up schedules
From: |
Alexandre Courbot |
Subject: |
Re: [Adonthell-devel] Speeding up schedules |
Date: |
30 Apr 2002 14:00:36 +0200 |
> The thing to change are all these
>
> blah = self.myself.get_val ("blah") - 1
> self.myself.set_val ("blah", blah)
>
> Code like that is executed 50 or more times per second for every NPC!
> Fact is, this code originates from a time where the scripts weren't
> classes. There was no other way to store such counters other than the
> NPC itself. But now we could easily store stuff like this in class
> variables, which would be way more efficient.
>
> The only problem that comes up is saving and restoring the exact state
> of a NPC. For that purpose it _does_ make sense to store those things
> with the NPC. In the schedule constructor, the values can be read once
> and stored in class variables. In the destructor they are written back
> into the NPC. However, we'd also need a save_state function that writes
> them to the NPC before the NPC is saved.
That means we'd have to keep track of the variables we use and manually
save them in save_state, right? Maybe we could directly get the list of
members of the Python object, and save the variables. Or serialize the
object using the pickle module. There are several possibilities.
> That seems to be the easiest solution to me. And it would require only
> little changes to existing code. I'm not sure we should change the
> current scripts at all, but those scripts we are going to write for v0.4
> should make use of this optimization.
Sure. Changing the current schedules isn't very important, I think, as
Waste's Edge runs quite well already.
> So if you agree, I'll integrate this into the schedule manager proposed
> in my last mail. (But I might make a few tests with Waste's Edge
> nontheless).
Sounds good. At least it's better than what we currently have! :)
Alex.
--
http://www.gnurou.org