Open johndoknjas opened 11 months ago
I am not entirely sure whether this functionality is part of our responsibility. Actually, the user themself should be able to install a cache system if they make multiple requests that would benefit from such a system. But if we have the capacity, we can of course implement it anyway. Optimally with the possibility to de/activate it.
E.g., for a command like "d", we could save the board string the first time it's obtained, and then just return that variable whenever
get_board_visual()
is called again. It would have to be reset to None though whenever the fen is updated. I did this for one of my other projects, in this commit (just the changes in models.py). This idea could also be implemented for things likeget_fen_position()
.A drawback of doing this would be slightly increasing the complexity of the codebase. In addition, I'm not sure how many users will be repeatedly calling either of the above functions, to such an extent that this optimization will help a lot. In my project it helped since I was sometimes calling
get_what_is_on_square()
hundreds of times for a single given position, and each call in turn calledget_board_visual()
.