[issue2159] dbmmodule inquiry function is performance prohibitive

Jesús Cea Avión report at bugs.python.org
Mon Mar 24 23:46:50 CET 2008


Jesús Cea Avión <jcea at argo.es> added the comment:

I think that "-1" is a sanity check. If the count is updated in the
database, but it is not transactional (or there are bugs, or the DB is
updated by a not up-to-date library, and so on), the cached counter and
the real data can diverge.

Anybody using "Berkeley DB" related databases knows that "length" is
costly. By good reasons, actually :-).

Checking for empty databases should be fast, nevertheless (just iterate
over the first item in the database). We could simply define a
"__nonzero__()" method for that. That would solve the "if" issue.

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2159>
__________________________________


More information about the Python-bugs-list mailing list