docs: def open(filename, flag='c', protocol=None, writeback=False,
           maxsize=DEFAULT_MAXSIZE, timeout=DEFAULT_TIMEOUT):
      """Open a database file as a persistent dictionary.
  
      The persistent dictionary file is opened using :func:`dbm.open`, so
      performance will depend on which :mod:`dbm` modules are installed.
  
      :func:`open` chooses to open a :class:`Shelf <shelve.Shelf>`,
      :class:`LRUShelf`, :class:`TimeoutShelf`, or :class:`LRUTimeoutShelf`
      depending on the values of keyword arguments *maxsize* and *timeout*.
      A :data:`None` value for *maxsize* and *timeout* will disable the LRU
      cache management and automatic data timeout features respectively.
  
      :param filename: The base filename for the underlying database that is
          passed to :func:`dbm.open`.
      :param flag: The flag to pass to :func:`dbm.open`.
      :param protocol: The pickle protocol to pass to :func:`pickle.dump`.
      :param writeback: Whether or not to write back all accessed entries on
          :meth:`Shelf.sync <shelve.Shelf.sync>` and
          :meth:`Shelf.close <shelve.Shelf.close>`
      :type writeback: bool
      :param maxsize: The maximum size the container is allowed to grow to.
          ``0`` means that no size limit is enforced. :data:`None` means that
          LRU cache management is disabled.
      :type maxsize: integer or :data:`None`
      :param timeout: The default timeout value for data (in seconds). ``0``
          means that the data never expires. :data:`None` means that automatic
          timeout features will be disabled.
      :type timeout: integer or :data:`None`
      :return: A shelf
      :rtype: :class:`~shelve.Shelf`, :class:`LRUShelf`, :class:`TimeoutShelf`,
          or :class:`LRUTimeoutShelf`
  
      """
      import dbm
      dict = dbm.open(filename, flag)
      if maxsize is None and timeout is None:
          return Shelf(dict, protocol, writeback)
      elif maxsize is None:
          return TimeoutShelf(dict, protocol, writeback, timeout=timeout)
      elif timeout is None:
          return LRUShelf(dict, protocol, writeback, maxsize=maxsize)
      return LRUTimeoutShelf(dict, protocol, writeback, timeout=timeout,
                             maxsize=maxsize)