[issue2159] dbmmodule inquiry function is performance prohibitive

Jesús Cea Avión report at bugs.python.org
Thu Apr 24 00:38:31 CEST 2014


Jesús Cea Avión added the comment:

First, Python 2.4 has been out of support for a really long time. Deleting.

Eric, let me clarify the situation, because this report is old and I forgot the details.

I think current situation is this, when doing something like "if db : DO_SOMETHING":

a) If the database is closed, raise an exception.

b) If database is empty, returns False.

c) If database has any entry, returns True. Takes time proportional to database length, because it is going to go thru it.

The patch you are proposing:

a) If the database is closed, raise an exception.

b) If database is empty, returns 0.

c) If database has any entry, returns 1. Fast and simply checking if the database has at least a single record.

Why 0/1 instead of True/False?. This is going to be a 3.5 patch, True/False are really there, they are not aliases.

PS: When done, I will probably port this patch to current "pybsddb" work, although I am not sure that Berkeley DB has "firstkey" for all database types it support. Would you allow this porting, Eric? https://pypi.python.org/pypi/bsddb3/6.0.1

----------
versions:  -Python 2.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2159>
_______________________________________


More information about the Python-bugs-list mailing list