cython.py 682 B

123456789101112131415161718192021222324252627
  1. """ Exports a no-op 'cython' namespace similar to
  2. https://github.com/cython/cython/blob/master/Cython/Shadow.py
  3. This allows to optionally compile @cython decorated functions
  4. (when cython is available at built time), or run the same code
  5. as pure-python, without runtime dependency on cython module.
  6. We only define the symbols that we use. E.g. see fontTools.cu2qu
  7. """
  8. from types import SimpleNamespace
  9. def _empty_decorator(x):
  10. return x
  11. compiled = False
  12. for name in ("double", "complex", "int"):
  13. globals()[name] = None
  14. for name in ("cfunc", "inline"):
  15. globals()[name] = _empty_decorator
  16. locals = lambda **_: _empty_decorator
  17. returns = lambda _: _empty_decorator