diff options
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 42c36a6fa3..f92b1e4980 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -331,13 +331,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 |