deuces
deuces copied to clipboard
5x SpeedUp
I tried to re-write this code with cython On my dev branch
$ python3 perf_deuces.py 7 card evaluation: [] Deuces: Average time per evaluation: 0.000006 [] Decues: Evaluations per second = 155845.607360 6 card evaluation: [] Deuces: Average time per evaluation: 0.000004 [] Decues: Evaluations per second = 283565.609514 5 card evaluation: [] Deuces: Average time per evaluation: 0.000001 [] Decues: Evaluations per second = 1019817.156195
On master branch
$ python2 perf_deuces.py 7 card evaluation: [] Deuces: Average time per evaluation: 0.000038 [] Decues: Evaluations per second = 26337.395638 6 card evaluation: [] Deuces: Average time per evaluation: 0.000013 [] Decues: Evaluations per second = 78230.631209 5 card evaluation: [] Deuces: Average time per evaluation: 0.000002 [] Decues: Evaluations per second = 430052.701733
I don't expect cython can beat C implementation, while I think we can find a balance between python's convinience and performance.
I hope you can have a try on my fork. Looking to your ideas.
This is very cool.
What would be the steps to run? For compilation of the cython? If we merge this I just want to have clear instructions for people to use.
What would be the steps to run?
Nothing changed, only need to guarantee that cython has been installed successfully.
I used import pyximport; pyximport.install()
. All the compilation job would be finished automatically. See http://docs.cython.org/en/latest/src/tutorial/cython_tutorial.html#pyximport-cython-compilation-the-easy-way
I'm glad that you are interested in merging it, but I think we still have some job to do:
- Have not tested on Python 2 (unless drop the support for Py2)
- Potential memory leak
- Terrible code style
My suggest:
- Fork current master branch to legacy_for_py2
- Merge my code to worldveil/deuces dev branch
- After finishing these job, merge into master branch
@Endle can you explain how to better build this into my project?
I have Cython installed, within the environment I executed python setup.py install
within the deuces directory ( python 3.7 )
When I open a shell and execute an import I receive the following error:
Python 3.7.0 (default, Jul 3 2018, 14:00:44)
[Clang 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyximport; pyximport.install()
(None, <pyximport.pyximport.PyxImporter object at 0x103878048>)
>>> import deuces
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/chris/.virtualenvs/capoker/lib/python3.7/site-packages/deuces-0.1-py3.7.egg/deuces/__init__.py", line 2, in <module>
ModuleNotFoundError: No module named 'deuces.card'
@chrisking Could you please consider run pip3 install -e .
instead of python setup.py install
?
I don't know why, but my dev branch still works fine on my computer
https://github.com/Endle/deuces/tree/dev
@Endle that worked perfectly, that means to patch it we'll need an updated setup.py file. Not a huge priority but now we know where the issue is.