Commit b760c4b8 authored by Jason Madden's avatar Jason Madden

docstring spacing adjustment.

parent d4d19019
...@@ -19,8 +19,7 @@ from zope.interface import Interface ...@@ -19,8 +19,7 @@ from zope.interface import Interface
from zope.interface import implementer from zope.interface import implementer
class IRing(Interface): class IRing(Interface):
""" """Conceptually, a doubly-linked list for efficiently keeping track of least-
Conceptually, a doubly-linked list for efficiently keeping track of least-
and most-recently used :class:`persistent.interfaces.IPersistent` objects. and most-recently used :class:`persistent.interfaces.IPersistent` objects.
This is meant to be used by the :class:`persistent.picklecache.PickleCache` This is meant to be used by the :class:`persistent.picklecache.PickleCache`
...@@ -30,41 +29,41 @@ class IRing(Interface): ...@@ -30,41 +29,41 @@ class IRing(Interface):
""" """
def __len__(): def __len__():
""" """Return the number of persistent objects stored in the ring.
Return the number of persistent objects stored in the ring. Should
be constant time. Should be constant time.
""" """
def __contains__(object): def __contains__(object):
""" """Answer whether the given persistent object is found in the ring.
Answer whether the given persistent object is found in the ring.
Must not rely on object equality or object hashing, but only Must not rely on object equality or object hashing, but only
identity or the `_p_oid`. Should be constant time. identity or the `_p_oid`. Should be constant time.
""" """
def add(object): def add(object):
""" """Add the persistent object to the ring as most-recently used.
Add the persistent object to the ring as most-recently used. When
an object is in the ring, the ring holds a strong reference to When an object is in the ring, the ring holds a strong
it so it can be deactivated later by the pickle cache. Should reference to it so it can be deactivated later by the pickle
be constant time. cache. Should be constant time.
The object should not already be in the ring, but this is not necessarily The object should not already be in the ring, but this is not necessarily
enforced. enforced.
""" """
def delete(object): def delete(object):
""" """Remove the object from the ring if it is present.
Remove the object from the ring if it is present. Returns a true
value if it was present and a false value otherwise. An ideal Returns a true value if it was present and a false value
implementation should be constant time, but linear time is otherwise. An ideal implementation should be constant time,
allowed. but linear time is allowed.
""" """
def move_to_head(object): def move_to_head(object):
""" """Place the object as the most recently used object in the ring.
Place the object as the most recently used object in the ring. The
object should already be in the ring, but this is not The object should already be in the ring, but this is not
necessarily enforced, and attempting to move an object that is necessarily enforced, and attempting to move an object that is
not in the ring has undefined consequences. An ideal not in the ring has undefined consequences. An ideal
implementation should be constant time, but linear time is implementation should be constant time, but linear time is
...@@ -72,9 +71,10 @@ class IRing(Interface): ...@@ -72,9 +71,10 @@ class IRing(Interface):
""" """
def delete_all(indexes_and_values): def delete_all(indexes_and_values):
""" """Given a sequence of pairs (index, object), remove all of them from
Given a sequence of pairs (index, object), remove all of them from the ring.
the ring. This should be equivalent to calling :meth:`delete` for each
This should be equivalent to calling :meth:`delete` for each
value, but allows for a more efficient bulk deletion process. value, but allows for a more efficient bulk deletion process.
If the index and object pairs do not match with the actual state of the If the index and object pairs do not match with the actual state of the
...@@ -84,19 +84,20 @@ class IRing(Interface): ...@@ -84,19 +84,20 @@ class IRing(Interface):
""" """
def __iter__(): def __iter__():
""" """Iterate over each persistent object in the ring, in the order of least
Iterate over each persistent object in the ring, in the order of least recently used to most recently used.
recently used to most recently used. Mutating the ring while an iteration
is in progress has undefined consequences. Mutating the ring while an iteration is in progress has
undefined consequences.
""" """
from collections import deque from collections import deque
@implementer(IRing) @implementer(IRing)
class _DequeRing(object): class _DequeRing(object):
""" """A ring backed by the :class:`collections.deque` class.
A ring backed by the :class:`collections.deque` class. Operations
are a mix of constant and linear time. Operations are a mix of constant and linear time.
It is available on all platforms. It is available on all platforms.
""" """
...@@ -167,8 +168,7 @@ else: ...@@ -167,8 +168,7 @@ else:
#pylint: disable=E1101 #pylint: disable=E1101
@implementer(IRing) @implementer(IRing)
class _CFFIRing(object): class _CFFIRing(object):
""" """A ring backed by a C implementation. All operations are constant time.
A ring backed by a C implementation. All operations are constant time.
It is only available on platforms with ``cffi`` installed. It is only available on platforms with ``cffi`` installed.
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment