Coverage for /pythoncovmergedfiles/medio/medio/src/python-crc32c/src/google_crc32c/__init__.py: 64%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Copyright 2018 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
15import warnings
17_SLOW_CRC32C_WARNING = (
18 "As the c extension couldn't be imported, `google-crc32c` is using a "
19 "pure python implementation that is significantly slower. If possible, "
20 "please configure a c build environment and compile the extension"
21)
23# Default to C exstension Implementation, falling back to pure python.
24try:
25 from google_crc32c import cext as impl
26 implementation = "c"
27except ImportError as exc:
28 from google_crc32c import python as impl # type: ignore
29 warnings.warn(_SLOW_CRC32C_WARNING, RuntimeWarning)
30 implementation = "python"
32extend = impl.extend
33value = impl.value
35Checksum = impl.Checksum
37__all__ = ["extend", "value", "Checksum", "implementation"]