[Tutor] slow html generation code
Sean Perry
shaleh at speakeasy.net
Thu Mar 3 01:12:45 CET 2005
Luis N wrote:
> This code seems a little slow, is there anything in particular that
> jumps out as being not quite right.
>
> The idea is that a file is opened that contains path names to other
> files, that are appended and outputed into a directory of choice.
>
> I plan to move this off the filesystem into a database when the
> concept is worked out, maybe that will help.
>
You are reading entire file contents into memory. Once with
f.readlines() and then again with structure.read(). If these are
somewhat large files that could definitely be a place for slowness. If
nothing else, Python promises garbage collection to be done, but not
when. So many of your files could be sitting in memory.
More information about the Tutor
mailing list