diff options
author | Robert Schuppenies <okkotonushi@googlemail.com> | 2008-07-10 17:13:55 (GMT) |
---|---|---|
committer | Robert Schuppenies <okkotonushi@googlemail.com> | 2008-07-10 17:13:55 (GMT) |
commit | 476290299885a87b8b90b55bbfef067945e63913 (patch) | |
tree | 0256a50d68580213b98bb1baa63cdd65fbda4a96 /Doc | |
parent | 5930d8f05e501ac0327c8b752a21412b0fb97cae (diff) | |
download | cpython-476290299885a87b8b90b55bbfef067945e63913.zip cpython-476290299885a87b8b90b55bbfef067945e63913.tar.gz cpython-476290299885a87b8b90b55bbfef067945e63913.tar.bz2 |
Added garbage collector overhead and optional default return value to
sys.getsizeof.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/sys.rst | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 22397f2..871cec7 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -393,13 +393,20 @@ always available. :func:`setrecursionlimit`. -.. function:: getsizeof(object) +.. function:: getsizeof(object[, default]) Return the size of an object in bytes. The object can be any type of object. All built-in objects will return correct results, but this - does not have to hold true for third-party extensions as it is implementation + does not have to hold true for third-party extensions as it is implementation specific. + The *default* argument allows to define a value which will be returned + if the object type does not provide means to retrieve the size and would + cause a `TypeError`. + + func:`getsizeof` calls the object's __sizeof__ method and adds an additional + garbage collector overhead if the object is managed by the garbage collector. + .. versionadded:: 2.6 |