user15765: I want to try some reinforcement learning techniques (borrowed from AlphaZero, etc.) and so I need a chess environment in order to run games.
I code in python, so I found python-chess but unfortunately it is too slow to generate a large amount of games. Playing 100 games with random moves (average length of ~400 moves for a random game) takes 8 seconds, which doesn't scale to higher orders of magnitude well. My profiling shows that over 99.9% of the time taken is with the library as opposed to other code, so I can't optimize any further.
Is there already an existing chess environment that is faster than this in python?

user825: Generating high volume of data directly in an interpreting Python environment is a bad idea. Furthermore, the python-chess package is not made for high performance; the package is not a wrapper for native C/C++.
If you want to generate hundreds and thousands of games quickly, you don't have any reason for avoiding native coding such as C++. Take the Stockfish code base, modify it for making games. That was what the Leela project had done, and it worked!
Please consider going into C++. Mutlit-threading if you haven't done it already.

15765: <p>I want to try some reinforcement learning techniques (borrowed from AlphaZero, etc.) and so I need a chess environment in order to run games.</p>

<p>I code in python, so I found <a href="https://pypi.org/project/python-chess/" rel="nofollow noreferrer">python-chess</a> but unfortunately it is too slow to generate a large amount of games. Playing 100 games with random moves (average length of ~400 moves for a random game) takes 8 seconds, which doesn't scale to higher orders of magnitude well. My profiling shows that over 99.9% of the time taken is with the library as opposed to other code, so I can't optimize any further.</p>

<p>Is there already an existing chess environment that is faster than this in python?</p>
 825: <p>Generating high volume of data directly in an interpreting Python environment is a bad idea. Furthermore, the <code>python-chess</code> package is not made for high performance; the package is not a wrapper for native C/C++.</p>

<p>If you want to generate hundreds and thousands of games quickly, you don't have any reason for avoiding native coding such as C++. Take the Stockfish code base, modify it for making games. That was what the <code>Leela</code> project had done, and it worked!</p>

<p>Please consider going into C++. Mutlit-threading if you haven't done it already.</p>
