Coverage for /builds/kinetik161/ase/ase/utils/cext.py: 57.14%
14 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-12-10 11:04 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-12-10 11:04 +0000
1"""Use C-extensions from asecext.
3This module defines a decorator that can be used to replace pure Python
4functions with faster C-implementations from the ase_ext module.
5"""
7import functools
9try:
10 import ase_ext
11except ImportError:
12 ase_ext = None
15def cextension(func):
16 if ase_ext is None:
17 return func
18 cfunc = getattr(ase_ext, func.__name__, None)
19 if cfunc is None:
20 return func
21 functools.update_wrapper(cfunc, func)
22 cfunc.__pure_python_function__ = func
23 return cfunc