[PATCH] KnitIndex optimizations
Dmitry Vasiliev
lists at hlabs.spb.ru
Mon Nov 20 12:46:36 GMT 2006
Brief overview of the changes in the attached patch:
- Extracted the knit index file parsing code from __init__() into _load_data()
method. For the new code profiling tells about 15% speedup while parse all
*.kndx from the Bazaar branch.
- Converted loops into list comprehensions where appropriate.
- Localized attributes for faster access inside loops where appropriate.
- Added forgotten import.
- Removed trailing whitespaces.
Open questions:
- KnitVersionedFile._check_versions_present() method now just calls
self._index.check_versions_present(). The possible problem here is that
RevisionNotPresent exception now gets filename of the index instead of the base
filename of the knit. I'm not sure should the exception be caught at the
KnitVersionedFile level and be rerised with the knit's base filename?
- Maybe _load_data() should use file's iteration protocol instead of the
readlines() method for parse index file? A file iterator use read-ahead buffer
so it should be faster than file.readline() and should consume less memory (for
big files) while be a little bit slower than file.readlines(). For the
_load_data() method profiling tells about 10% speedup for 'for line in fp'
instead of 15% for 'for line in fp.readlines()'.
--
Dmitry Vasiliev (dima at hlabs.spb.ru)
http://hlabs.spb.ru
-------------- next part --------------
A non-text attachment was scrubbed...
Name: knit_index.patch
Type: text/x-patch
Size: 15047 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20061120/e986609b/attachment.bin
More information about the bazaar
mailing list