"""
The ``btree`` module implements a simple key-value database using external
storage (disk files, or in general case, a random-access `stream`). Keys are
stored sorted in the database, and besides efficient retrieval by a key
value, a database also supports efficient ordered range scans (retrieval
of values with the keys in a given range). On the application interface
side, BTree database work as close a possible to a way standard `dict`
type works, one notable difference is that both keys and values must
be `bytes` objects (so, if you want to store objects of other types, you
need to serialize them to `bytes` first).
The module is based on the well-known BerkelyDB library, version 1.xx.
Example::
 import btree
 # First, we need to open a stream which holds a database
 # This is usually a file, but can be in-memory database
 # using uio.BytesIO, a raw flash partition, etc.
 # Oftentimes, you want to create a database file if it doesn't
 # exist and open if it exists. Idiom below takes care of this.
 # DO NOT open database with "a+b" access mode.
 try:
     f = open("mydb", "r+b")
 except OSError:
     f = open("mydb", "w+b")
 # Now open a database itself
 db = btree.open(f)
 # The keys you add will be sorted internally in the database
 db[b"3"] = b"three"
 db[b"1"] = b"one"
 db[b"2"] = b"two"
 # Assume that any changes are cached in memory unless
 # explicitly flushed (or database closed). Flush database
 # at the end of each "transaction".
 db.flush()
 # Prints b'two'
 print(db[b"2"])
 # Iterate over sorted keys in the database, starting from b"2"
 # until the end of the database, returning only values.
 # Mind that arguments passed to values() method are *key* values.
 # Prints:
 #   b'two'
 #   b'three'
 for word in db.values(b"2"):
     print(word)
 del db[b"2"]
 # No longer true, prints False
 print(b"2" in db)
 # Prints:
 #  b"1"
 #  b"3"
 for key in db:
     print(key)
 db.close()
 # Don't forget to close the underlying stream!
 f.close()
"""

def open(stream, \*, flags=0, pagesize=0, cachesize=0, minkeypage=0):
    """
    Open a database from a random-access `stream` (like an open file). All
    other parameters are optional and keyword-only, and allow to tweak advanced
    parameters of the database operation (most users will not need them):
    * *flags* - Currently unused.
    * *pagesize* - Page size used for the nodes in BTree. Acceptable range
      is 512-65536. If 0, a port-specific default will be used, optimized for
      port's memory usage and/or performance.
    * *cachesize* - Suggested memory cache size in bytes. For a
      board with enough memory using larger values may improve performance.
      Cache policy is as follows: entire cache is not allocated at once;
      instead, accessing a new page in database will allocate a memory buffer
      for it, until value specified by *cachesize* is reached. Then, these
      buffers will be managed using LRU (least recently used) policy. More
      buffers may still be allocated if needed (e.g., if a database contains
      big keys and/or values). Allocated cache buffers aren't reclaimed.
    * *minkeypage* - Minimum number of keys to store per page. Default value
      of 0 equivalent to 2.
    Returns a BTree object, which implements a dictionary protocol (set
    of methods), and some additional methods described below.
    """
    pass

def abs():
    """
    .. function:: all()
    """
    pass

def all():
    """
    .. function:: any()
    """
    pass

def any():
    """
    .. function:: bin()
    """
    pass

def bin():
    """
    .. class:: bool()
    """
    pass

def callable():
    """
    .. function:: chr()
    """
    pass

def chr():
    """
    .. function:: classmethod()
    """
    pass

def classmethod():
    """
    .. function:: compile()
    """
    pass

def compile():
    """
    .. class:: complex()
    """
    pass

def delattr(obj, name):
    """
    The argument *name* should be a string, and this function deletes the named
    attribute from the object given by *obj*.
    """
    pass

def dir():
    """
    .. function:: divmod()
    """
    pass

def divmod():
    """
    .. function:: enumerate()
    """
    pass

def enumerate():
    """
    .. function:: eval()
    """
    pass

def eval():
    """
    .. function:: exec()
    """
    pass

def exec():
    """
    .. function:: filter()
    """
    pass

def filter():
    """
    .. class:: float()
    """
    pass

def getattr():
    """
    .. function:: globals()
    """
    pass

def globals():
    """
    .. function:: hasattr()
    """
    pass

def hasattr():
    """
    .. function:: hash()
    """
    pass

def hash():
    """
    .. function:: hex()
    """
    pass

def hex():
    """
    .. function:: id()
    """
    pass

def id():
    """
    .. function:: input()
    """
    pass

def input():
    """
    .. class:: int()
    .. classmethod:: from_bytes(bytes, byteorder)
       In MicroPython, `byteorder` parameter must be positional (this is
       compatible with CPython).
    .. method:: to_bytes(size, byteorder)
       In MicroPython, `byteorder` parameter must be positional (this is
       compatible with CPython).
    """
    pass

def isinstance():
    """
    .. function:: issubclass()
    """
    pass

def issubclass():
    """
    .. function:: iter()
    """
    pass

def iter():
    """
    .. function:: len()
    """
    pass

def len():
    """
    .. class:: list()
    """
    pass

def locals():
    """
    .. function:: map()
    """
    pass

def map():
    """
    .. function:: max()
    """
    pass

def max():
    """
    .. class:: memoryview()
    """
    pass

def min():
    """
    .. function:: next()
    """
    pass

def next():
    """
    .. class:: object()
    """
    pass

def oct():
    """
    .. function:: open()
    """
    pass

def open():
    """
    .. function:: ord()
    """
    pass

def ord():
    """
    .. function:: pow()
    """
    pass

def pow():
    """
    .. function:: print()
    """
    pass

def print():
    """
    .. function:: property()
    """
    pass

def property():
    """
    .. function:: range()
    """
    pass

def range():
    """
    .. function:: repr()
    """
    pass

def repr():
    """
    .. function:: reversed()
    """
    pass

def reversed():
    """
    .. function:: round()
    """
    pass

def round():
    """
    .. class:: set()
    """
    pass

def setattr():
    """
    .. class:: slice()
    The *slice* builtin is the type that slice objects have.
    """
    pass

def sorted():
    """
    .. function:: staticmethod()
    """
    pass

def staticmethod():
    """
    .. class:: str()
    """
    pass

def sum():
    """
    .. function:: super()
    """
    pass

def super():
    """
    .. class:: tuple()
    """
    pass

def type():
    """
    .. function:: zip()
    """
    pass

def zip():
    pass

