Skip to content

Commit

Permalink
Fix #328: Add note about maxsize being an actual number.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkem committed Feb 20, 2025
1 parent 72b4a32 commit c03a7ee
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ of the cache. When a cache is full, :meth:`Cache.__setitem__()` calls
:meth:`self.popitem()` repeatedly until there is enough room for the
item to be added.

.. note::

Please be aware that `maxsize` must be a positive number. If you
really want your cache to grow without bounds, use
:const:`math.inf` or something similar.

In general, a cache's size is the total size of its item's values.
Therefore, :class:`Cache` provides a :meth:`getsizeof` method, which
returns the size of a given `value`. The default implementation of
Expand All @@ -50,12 +56,12 @@ making the cache's size equal to the number of its items, or
named constructor parameter `getsizeof`, which may specify a function
of one argument used to retrieve the size of an item's value.

Note that the values of a :class:`Cache` are mutable by default, as
are e.g. the values of a :class:`dict`. It is the user's
responsibility to take care that cached values are not accidentally
modified. This is especially important when using a custom
`getsizeof` function, since the size of an item's value will only be
computed when the item is inserted into the cache.
The values of a :class:`Cache` are mutable by default, as are e.g. the
values of a :class:`dict`. It is the user's responsibility to take
care that cached values are not accidentally modified. This is
especially important when using a custom `getsizeof` function, since
the size of an item's value will only be computed when the item is
inserted into the cache.

.. note::

Expand Down

0 comments on commit c03a7ee

Please sign in to comment.