eliasdoehne / stellaris-dashboard

A graph dashboard and event log for Stellaris.
123 stars 14 forks source link

Add Cython language level to tokenizer.pyx #87

Closed chennin closed 1 year ago

chennin commented 1 year ago

I've been running the dashboard on Python 3.10 / Cython==0.29.32. The following error happens then, and also with Python 3.8 (same Cython version -- not sure when the FutureWarning was introduced). Whenever tokenizer.pyx gets compiled (manually: python setup.py build_ext --inplace), this warning is printed in red:

/home/stellaris/.local/lib/python3.10/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /home/stellaris/stellaris-dashboard/stellarisdashboard/parsing/cython_ext/tokenizer.pyx
  tree = Parsing.p_module(s, pxd, full_module_name)

Adding the language level to the top of the file silences it. And since Python 3 is required for this project, it seems like a good idea to use 3 here anyway.

As a bonus, in my test (2 runs each), language_level=3 parses one of my late-game save folders 10 seconds faster than the default language_level=2 (2m45s vs 2m55s)

eliasdoehne commented 1 year ago

Great!

FYI, I worked on a replacement for the save parser using rust in the summer, which I to want to integrate in the next 1-2 weeks (I got a ~10x improvement with it vs the current one and it could probably be optimized further). If it works out as I'm planning, it should replace the Cython part and the SaveFileParser class.