Gareth Rees <g...@garethrees.org> added the comment:

The proposed change adds a Boolean flag to os.path.getsize() so that it returns:

    os.stat(filename).st_blocks * 512

(where the 512 is the file system block size on Linux; some work is needed to 
make this portable to other operating systems).

The Boolean argument here would always be constant in practice -- that is, 
you'd always call it like this:

    virtual_size = os.path.getsize(filename, apparent=True)
    allocated_size = os.path.getsize(filename, apparent=False)

and never like this:

    x_size = os.path.getsize(filename, apparent=x)

where x varies at runtime.

The "no constant bool arguments" design principle [1] suggests that this should 
be added as a new function, something like os.path.getallocatedsize().

  [1] https://mail.python.org/pipermail/python-ideas/2016-May/040181.html

----------
nosy: +g...@garethrees.org

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41092>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to