Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, directory):
import lmdb
# map_size is the maximum database size but shouldn't fill up the
# virtual address space
map_size = (1 << 40 if sys.maxsize >= 2**32 else 1 << 28)
# writemap requires sparse file support otherwise the whole
# `map_size` may be reserved up front on disk
writemap = sys.platform.startswith('linux')
self.db = lmdb.open(directory,
subdir=True,
map_size=map_size,
sync=False,
writemap=writemap,
)