Mercurial > hgrepos > Python > apps > py-cutils
diff cutils/util/constants.py @ 117:e51f34ad6d71
Move constant definitions into new module cutils.util.constants
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 29 Dec 2024 17:39:00 +0100 |
| parents | |
| children | dfe7bb0579e2 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cutils/util/constants.py Sun Dec 29 17:39:00 2024 +0100 @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# :- +# :Copyright: (c) 2020-2022 Franz Glasner +# :License: BSD-3-Clause +# :- +r"""Common constants and compatibility definitions. + +""" + +__all__ = ["PY2", + "PATH_TYPES", + "READ_CHUNK_SIZE", + "MAX_AUTO_MAP_SIZE", + "MAP_WINDOW_SIZE" + ] + + +import sys +try: + import pathlib +except ImportError: + pathlib = None + + +PY2 = sys.version_info[0] < 3 + +if PY2: + PATH_TYPES = (unicode, str) # noqa: F821 (undefined name 'unicode') +else: + if pathlib: + PATH_TYPES = (str, bytes, pathlib.Path) + else: + PATH_TYPES = (str, bytes) + +READ_CHUNK_SIZE = 2 * 1024 * 1024 # like BUFSIZE_MAX on FreeBSD +MAX_AUTO_MAP_SIZE = 8 * 1024 * 1024 +MAP_WINDOW_SIZE = MAX_AUTO_MAP_SIZE # do not totally trash memory on big files
