dabo Commit
Revision 5656
Date: 2010-02-05 13:33:46 -0800 (Fri, 05 Feb 2010)
Author: Paul
Trac: http://trac.dabodev.com/changeset/5656
Changed:
U trunk/dabo/db/dCursorMixin.py
Log:
Pie on my face, the list comprehension is faster for all datasets larger than
500
records or so, and almost as fast for counts less than that.
Diff:
Modified: trunk/dabo/db/dCursorMixin.py
===================================================================
--- trunk/dabo/db/dCursorMixin.py 2010-02-05 19:08:40 UTC (rev 5655)
+++ trunk/dabo/db/dCursorMixin.py 2010-02-05 21:33:46 UTC (rev 5656)
@@ -1769,11 +1769,8 @@
def hasPK(self, pk):
"""Return True if the passed pk is present in the dataset."""
- pks = (v[self.KeyField] for v in self._records)
- for trial_pk in pks:
- if trial_pk == pk:
- return True
- return False
+ kf = self.KeyField
+ return bool([v[kf] for v in self._records if v[kf] == pk])
def moveToPK(self, pk):
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message:
http://leafe.com/archives/byMID/[email protected]