Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w...
by brucethemoose2 on Tuesday March 07, 2023 @11:53AM
(#35057616)
Civ4 used Python scripting, and it was a horrendous performance bottleneck :/
[ Parent
| on HN ]
Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w...
by hermitdev on Tuesday March 07, 2023 @12:11PM
(#35057927)
The Civ4 core game dll was its own bottleneck. It's is terribly inefficient c++. Years ago, I was working on my own mod to optimize it because I got tired of waiting 15 minutes for the AI to complete a turn on a huge map late game. It was not hard to get it down to just a few minutes. I think it could be used as a poster child for a code base written by someone expecting the optimizer to work miracles. Lots of macros hiding expensive call chains used in tight nested loops, repeated calls in loops to get the same item that should have been called once outside of the loop(s), etc.
Python was not the bottleneck, just the scapegoat for badly written code.
Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w...
by brucethemoose2 on Tuesday March 07, 2023 @02:54PM
(#35060304)
Yes, but (AFAIK) Python itself also became a bottleneck in the Civ4 gigamods, like the (still active) Caveman2Cosmos.
Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w...
by nurettin on Tuesday March 07, 2023 @04:03PM
(#35061172)
How did you even start optimizing Civ4? Did you replace some exported dll functions with your own? How did you access the state in memory?
Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w...
by hermitdev on Tuesday March 07, 2023 @06:48PM
(#35063111)
Firaxis provided the source for the core DLL for modding. Don't recall exactly when, but it may have been with the Beyond the Sword expansion.
Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w...
by wyldfire on Tuesday March 07, 2023 @11:59AM
(#35057721)
Python is the most incredible language because everything's dynamic. But it comes at an enormous cost - you can't make many assumptions or optimizations easily. It has tremendous utility for many applications. It's this utility and the wide body of existing software packages which makes it so tempting to use as a scripting engine. But it would be a bad move for any scripting that's in some critical region.
Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w...
by brucethemoose2 on Tuesday March 07, 2023 @03:02PM
(#35060402)
It would be nice to have an official, more performant statically typed/less dynamic subset of Python.
Yeah we have mypy, but its not official and not integrated. And subsets that do have a performance benefit (like TorchScript) are niche and/or not sustainably supported.
Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w...
by wyldfire on Tuesday March 07, 2023 @04:37PM
(#35061600)
Well -- other languages have shown up to try and fill this niche.
Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w...
by ben-schaaf on Tuesday March 07, 2023 @11:26PM
(#35065248)
Not statically typed, but rpython is a statically analyzable subset of python that is used to write pypy: https://rpython.readthedocs.io/en/latest/rpython.html
Re:RustPython – A Python-3 (CPython >= 3.11.0) Interpreter w...
by brucethemoose2 on Tuesday March 07, 2023 @11:42PM
(#35065342)
That looks very reasonable. Converting a Python codebase would be much easier than porting to a new language.
Now all your imports, on the other hand...