Odd wording it docs for shutil.move?
Rhodri James
rhodri at kynesim.co.uk
Fri Mar 3 12:27:29 EST 2017
On 03/03/17 17:22, Chris Warrick wrote:
> On 3 March 2017 at 18:13, Grant Edwards <grant.b.edwards at gmail.com> wrote:
>> At https://docs.python.org/2/library/shutil.html it says:
>>
>> shutil.move(src, dst)
>>
>> Recursively move a file or directory (src) to another location
>> (dst).
>>
>> [...]
>>
>> If the destination is on the current filesystem, then os.rename()
>> is used. Otherwise, src is copied (using shutil.copy2()) to dst
>> and then removed.
>>
>> What does the current filesystem have to do with anything?
>>
>> Surely, what matters is whether <src> and <dst> are on the same
>> filesystem?
>
> For the same reason it matters for /bin/mv. If the source and target
> are on the same filesystem, the files are just renamed, which is
> usually instantaneous (only file metadata needs to be changed). But if
> they are on different filesystems, “move” really means “copy and
> delete original”, which takes much longer.
Exactly Grant's point. The shutil.move documentation talks about the
*current* filesystem, not the filesystem on which <src> is located.
--
Rhodri James *-* Kynesim Ltd
More information about the Python-list
mailing list