Add cython support for timers
Add start
and stop
for cython. Things to think about:
- The cython code should not "spill into" the python code -- this means that the cython profiling should stay within cython.
- Likely consequence is that the cython profile DB needs to be interlaced with the python version
- Cython doesn't have metaclasses
- Cython doesn't do function decorators
Resources:
Cython "Almost" Metaclasses
https://stackoverflow.com/questions/51245056/singleton-is-not-working-in-cython
cdef class Singleton:
_instances = {}
@classmethod
def instance(cls, *args, **kwargs):
if cls not in cls._instances:
cls._instances[cls] = cls(*args, **kwargs)
return cls._instances[cls]
cdef class MyCythonClass(Singleton):
pass
c = MyCythonClass.instance()
d = MyCythonClass.instance()
c is d # True
Calling Timers from Cython
https://stackoverflow.com/questions/25533293/how-to-call-time-from-time-h-with-cython
from libc.time cimport time,time_t
cdef time_t t = time(NULL)
print t