[Zope-CMF] cmf zpt_generic/search - sequence_length is very slow
for large collections, len () is much faster.
fg at nuxeo.com
Thu Dec 23 12:21:37 EST 2004
Henryk Paluch <hpaluch at gitus.cz> wrote:
> >batch_obj.sequence_length returns the length of all the results.
> >len(batch_obj) returns only the length of the current batch slice.
> >Code is in ZTUtils/Batch.py
> Agreed, but I do
> len(items) but not len(batch_obj) :
Ah sorry I missed that.
> items = ctool.searchResults(kw)
> batch_obj = Batch(items, 25, b_start, orphan=1)
> length = batch_obj.sequence_length
> ### my guess: len(items)==batch_obj.sequence_length
> ### - but len(items) is much faster.
Well then that's strange, because in the end batch_obj.sequence_length
does just call lazily len(items). From reading the code I think there
shouldn't be any speed difference. Are you sure about your measurements?
Florent Guillaume, Nuxeo (Paris, France) CTO, Director of R&D
+33 1 40 33 71 59 http://nuxeo.com fg at nuxeo.com
More information about the Zope-CMF