Re: [Python-checkins] CVS: python/dist/src/Lib SimpleHTTPServer.py,1.10,1.11

is it worth replacing a couple of lines of obvious code with a reference to a little-used module? and if I want to, how do I tweak the block size? </F>

On Sat, 29 Jul 2000, Fredrik Lundh wrote:
is it worth replacing a couple of lines of obvious code with a reference to a little-used module?
I believe so. So did everyone when the thread came up on Python-Dev a couple of weeks ago -- I haven't followed up with the checkin for so long because of technical problems (AKA lack of computer).
and if I want to, how do I tweak the block size?
Just like you would in the old days: subclass SimpleHTTPServer, and substitute the copyfile method with a call to shutil.copyfile with a non-default size. (IOW, it's easier then what it was before).

</F>
and if I want to, how do I tweak the block size?
[Moshe]
I think thats a little of an overkill. It requires duplicating the entire method for the sake of one constant. def copyfile(self, source, outputfile): BLOCKSIZE = 8192 to def copyfile(self, source, outputfile, blocksize = 8192): is much more reasonable IMO. Mark.

On Sat, 29 Jul 2000, Mark Hammond wrote: </F>
and if I want to, how do I tweak the block size?
[Moshe]
[Mark]
I think thats a little of an overkill. It requires duplicating the entire method for the sake of one constant.
But Mark, the "entire method" is simply a call to shutil.copyfileobj (well, that and a docstring). So "duplicating" it is the only thing possible, unless you want to define a class variable "BLOCKSIZE". It can be supported without duplicating the functionality of shutil.copyfileobj, but that sure sounds like an overkill.... -- Moshe Zadka <moshez@math.huji.ac.il> There is no IGLU cabal. http://advogato.org/person/moshez

But Mark, the "entire method" is simply a call to shutil.copyfileobj
OK - I looked at it before I updated CVS! Oops :-)
Huh? Well, shutil.copyfileobj appears to have a "length" param, which is exactly what was being asked for (although possibly a poor choice of a name!). It is still more resonable to add a default param than to require a subclass. The shutil author clearly thought so! Mark.

On Sat, 29 Jul 2000, Mark Hammond wrote: [About SimpleHTTPServer.copyfile always using the default block-size]
It is still more resonable to add a default param than to require a subclass. The shutil author clearly thought so!
Ani Zatar! I'm the shutil.copyfileobj function author, and the circumstances are different. SimpleHTTPServer.copyfile is called by the methods which are not overridable (in the sense of overriding them being supported), so there is no sense in adding a default parameter -- you need to have something persistent in the class for that: and that is either a variable or method. PS. The "Ani Zatar" part is in case some Israeli reads the archive: it's a non-funny joke in Hebrew, and I won't translate it. -- Moshe Zadka <moshez@math.huji.ac.il> There is no IGLU cabal. http://advogato.org/person/moshez

On Sat, 29 Jul 2000, Fredrik Lundh wrote:
is it worth replacing a couple of lines of obvious code with a reference to a little-used module?
I believe so. So did everyone when the thread came up on Python-Dev a couple of weeks ago -- I haven't followed up with the checkin for so long because of technical problems (AKA lack of computer).
and if I want to, how do I tweak the block size?
Just like you would in the old days: subclass SimpleHTTPServer, and substitute the copyfile method with a call to shutil.copyfile with a non-default size. (IOW, it's easier then what it was before).

</F>
and if I want to, how do I tweak the block size?
[Moshe]
I think thats a little of an overkill. It requires duplicating the entire method for the sake of one constant. def copyfile(self, source, outputfile): BLOCKSIZE = 8192 to def copyfile(self, source, outputfile, blocksize = 8192): is much more reasonable IMO. Mark.

On Sat, 29 Jul 2000, Mark Hammond wrote: </F>
and if I want to, how do I tweak the block size?
[Moshe]
[Mark]
I think thats a little of an overkill. It requires duplicating the entire method for the sake of one constant.
But Mark, the "entire method" is simply a call to shutil.copyfileobj (well, that and a docstring). So "duplicating" it is the only thing possible, unless you want to define a class variable "BLOCKSIZE". It can be supported without duplicating the functionality of shutil.copyfileobj, but that sure sounds like an overkill.... -- Moshe Zadka <moshez@math.huji.ac.il> There is no IGLU cabal. http://advogato.org/person/moshez

But Mark, the "entire method" is simply a call to shutil.copyfileobj
OK - I looked at it before I updated CVS! Oops :-)
Huh? Well, shutil.copyfileobj appears to have a "length" param, which is exactly what was being asked for (although possibly a poor choice of a name!). It is still more resonable to add a default param than to require a subclass. The shutil author clearly thought so! Mark.

On Sat, 29 Jul 2000, Mark Hammond wrote: [About SimpleHTTPServer.copyfile always using the default block-size]
It is still more resonable to add a default param than to require a subclass. The shutil author clearly thought so!
Ani Zatar! I'm the shutil.copyfileobj function author, and the circumstances are different. SimpleHTTPServer.copyfile is called by the methods which are not overridable (in the sense of overriding them being supported), so there is no sense in adding a default parameter -- you need to have something persistent in the class for that: and that is either a variable or method. PS. The "Ani Zatar" part is in case some Israeli reads the archive: it's a non-funny joke in Hebrew, and I won't translate it. -- Moshe Zadka <moshez@math.huji.ac.il> There is no IGLU cabal. http://advogato.org/person/moshez
participants (3)
-
Fredrik Lundh
-
Mark Hammond
-
Moshe Zadka