From: Kees B. <kee...@xs...> - 2006-12-04 20:51:02
|
Hi, A few days ago I reported problems with scrolling in the people view. Don pointed at src/DisplayModels/_PeopleModel.py where LRU is used to speed up certain database lookups. Despite what Don was saying it is implemented as follows: def column_name(self, data, node): try: name = self.lru_name[node] except: name = NameDisplay.displayer.raw_sorted_name(data[PeopleModel._NAME_COL]) self.lru_name[node] = name return name (There are four data items handled this way. One of them slightly more complex.) Today I read some notes about performance issue with try-except. And I've done a bit of testing with a small test program. The thing is (just as it is in C++) try-except is not cheap wrt performance. The following code is (for this snippet) almost 10 times faster. (Depends a lot on the hit-rate, of course.) def column_name(self, data, node): if node in self.lru_name: name = self.lru_name[node] else: name = NameDisplay.displayer.raw_sorted_name(data[PeopleModel._NAME_COL]) self.lru_name[node] = name return name (And this is more or less what Don wrote in his email.) Now, what does this all mean? Unfortunately not a whole lot. I've changed the code as described above, but I couldn't see any performance change. Bummer. Then I tried a version without LRU and even that did not make a change. Just to verify that my modification were use I placed logging, and the logging was there. Needless to say I'm puzzled and I wanted to let you know :-) - Kees |