Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
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