[ftputil] tell() method for FTPFile objects
Stefan Schwarzer
sschwarzer at sschwarzer.net
Mon Jan 31 08:39:16 MET 2005
Hi Justin
On Monday 31 January 2005 03:28, Justin Ezequiel wrote:
> > > Summary: _Unless you also need a "seek" method_, I would see if
> > > I can add a "tell" method, but _only_ for binary transfers.
> > > Please reply.
After posting my original reply, it occured to me that not everybody
might have seen that there was a thorougher explanation on "tell" and
"seek" implementations towards the end of the mail.
> > I'll have to check zipfile first if it needs a seek method. Thank
> > you for the prompt reply.
> >
> >From browsing zipfile.py, it seems I'll also need a seek() method.
>
> In the meantime, I'll just use a temporary local file.
Partial quote from my original reply:
> Note that there will probably never be a "seek" method because the
> file object which I get from the socket's "makefile" method has no
> "seek" method (you can't reposition on the remote side without
> "reading forward" anyway). On the other hand, if someone really
> needs "seek" to just satisfy an interface, a "seek" method can
> probably be implemented. But it will be very slow (e. g. you have to
> read virtually the whole file over the network to position at the
> file's last byte).
The temporary file solution will probably be much faster than using a
"seek" method (if I would implement it):
Temporary file solution: You download the original data, compress it
and upload the compressed file. For the compression, zipfile uses the
fast seek method of the random-access file system.
Potential FTPFile.seek solution: Since zipfile wants to compress the
whole file, it has to download the whole file implicitly (even if not
at once). zipfile will also have to write all the compressed data to
the remote FTP server. However, a seek method implemented for FTPFile
would be much slower (see my quote). You end up transferring much
more data over the network than with the temporary file solution.
Stefan
More information about the ftputil
mailing list