Python example: possible speedup?
Hrvoje Niksic
hniksic at srce.hr
Wed Sep 8 14:06:42 EDT 1999
More information about the Python-list mailing list
Wed Sep 8 14:06:42 EDT 1999
- Previous message (by thread): Python example: possible speedup?
- Next message (by thread): Python example: possible speedup?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
John Mitchell <johnm at magnet.com> writes: > A few suggestions: > > 1) almost never use a catch-all-exceptions block. For example, in your > next_header method. I don't think it causes a slowdown, but point taken. > 2) avoid doing semi-slow operations in the middle of a loop: > > - string addition (self.__current = self.__current + line) As I said in the original message, I've tried to optimize this by making self.__current a list, but it didn't work any faster. > - reading a file one line at a time (self.__fp.readline()) I don't see an alternative to this, except to read the whole file at once, which I am trying to avoid, as the files are large. > 3) lambdas are fun, but very slow. I am almost completely sure that the sort you refer to is not the cause of the slowdown. > 4) objects are your friend. Dont know about speed, but they > simplify code *so much* that I always use them, even for dump > dictionary-like and list-like things. I don't really understand this. I'll study your code and see if it's clearer then.
- Previous message (by thread): Python example: possible speedup?
- Next message (by thread): Python example: possible speedup?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list