AB-CE / abce

Agent-based computational Economics, the Python library that makes AB modelling easier
http://abce.readthedocs.io
181 stars 62 forks source link

Trade: Use mypy annotation for cythonization instead of via .pyx file #178

Closed rht closed 5 years ago

rht commented 5 years ago

@DavoudTaghawiNejad here is the benchmark result of running unittest on my machine:

current master:

mypy-cython:

pure python:

rht commented 5 years ago

@DavoudTaghawiNejad, @DavoudTaghawiNejad, @DavoudTaghawiNejad the 4th commit (even though the change is minimum) speeds up the unittest runtime a lot:

python start.py  106.95s user 23.05s system 200% cpu 1:04.73 total
python start.py  107.39s user 23.18s system 201% cpu 1:04.83 total
rht commented 5 years ago

@DavoudTaghawiNejad this is the optimal level of annotation. Precisifying further (e.g. replacing sender's object with tuple) etc only makes it worse.

DavoudTaghawiNejad commented 5 years ago

Issue 167 must be merged in first. It's a nasty floating point error.

rht commented 5 years ago

The other option is to use .pxd files instead.

rht commented 5 years ago

Superseded by #182.