[PATCH] util: increase the copy buffer size in shutil's copyfile
Augie Fackler
raf at durin42.com
Fri May 6 21:12:12 UTC 2016
On Fri, May 6, 2016 at 5:11 PM, Tony Tung via Mercurial-devel
<mercurial-devel at mercurial-scm.org> wrote:
>> On May 6, 2016, at 1:50 PM, Augie Fackler <raf at durin42.com> wrote:
>>
>> On Fri, May 06, 2016 at 01:36:41PM -0700, Tony Tung wrote:
>>> # HG changeset patch
>>> # User Tony Tung <ttung at fb.com>
>>> # Date 1462566734 25200
>>> # Fri May 06 13:32:14 2016 -0700
>>> # Branch stable
>>> # Node ID edee9b1c3a2849fcb11900959ad785b202608c4f
>>> # Parent 97811ff7964710d32cae951df1da8019b46151a2
>>> util: increase the copy buffer size in shutil's copyfile
>>> +
>>> +def copyfileobj_lgbuffer(orig, *args, **kwargs):
>>> + if len(args) == 2 and 'length' not in kwargs:
>>> + args = (args[0], args[1], (4 * 1024 * 1024))
>>> +
>>> + orig(*args, **kwargs)
>>> +
>>> +wrap(shutil, 'copyfileobj', copyfileobj_lgbuffer)
>>
>> Why are you monkeypatching shutil's implementation here? I'm happy to
>> have a helper method in util, but I'm deeply skeptical of
>> monkeypatching the stdlib, doubly so when it's a method we don't
>> currently call outside of a test.
>
> copyfileobj is called by copyfile. copyfile does not expose the length parameter. Either we copypasta copyfile from shutil or we monkey patch copyfileobj’s default. I’m not particularly wedded to either approach as each has its own downside.
>
> Is the helper method you’re suggesting the copypaste approach?
Yep. Don't monkeypatch the stdlib.
>
> Thanks,
> Tony
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list