view cutils/util/constants.py @ 323:48430941c18c

Adopt copyright and license wordings from https://reuse.software/faq/. While there normalize copyright years for every file to start with the file's addition to the project (i.e. with the year of file creation).
author Franz Glasner <fzglas.hg@dom66.de>
date Wed, 26 Mar 2025 18:42:23 +0100
parents 0f4febf646f5
children
line wrap: on
line source

# -*- coding: utf-8 -*-
# :-
# SPDX-FileCopyrightText: © 2024-2025 Franz Glasner
# SPDX-License-Identifier: BSD-3-Clause
# :-
r"""Common constants and compatibility definitions.

"""

from __future__ import print_function, absolute_import


__all__ = ["PATH_TYPES",
           "READ_CHUNK_SIZE",
           "MAX_AUTO_MAP_SIZE",
           "MAP_WINDOW_SIZE"
           ]


try:
    import pathlib
except ImportError:
    pathlib = None

from . import PY2


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