[Image-SIG] less disk IO

Douglas Bagnall douglas at paradise.net.nz
Thu Jan 3 04:17:36 CET 2008


Carl Karsten wrote:

> I am trying to convert a pdf (data in string, not disk file) to a png.  This 
> will be run in a django view on a server (PyCon's even) so it would be good if 
> it didn't hit the disk as much.  Shouldn't I be able to use .tostring if I can 
> use .save?

use cStringIO.

http://docs.python.org/lib/module-StringIO.html

It might not make much difference, because your OS should be caching the
file in memory anyway, and letting you read it back before it is
actually written to disk.

If you are sure it is a disk problem, you could set it up to write to a
ram file system (e.g. tmpfs on linux), which would help the PDF
conversion too.

Otherwise you could see if it possible to communicate with the convert
script using pipes, rather than system(). That will cut out a few reads
and writes.


Douglas


More information about the Image-SIG mailing list