Caching and lazy objects.
A feature of the scripted cad is the need to restart the geometry generation script every time the model is updated. As the size of the model grows, this leads to a significant increase in the time required for calculating and drawing geometry. To solve this problem, computationally intensive ZenCad operations are cached and lenified by the [evalcache] library (https://github.com/mirmik/evalcache).
Instead of calculating directly, evalcache builds a model building tree based on the hash keys of the generated objects. The library saves all performed calculations in the cache on the hard disk and, if the object has already been calculated earlier, retrieves it from the cache. evalcache monitors changes in parameters in the model tree and updates computation objects that have ceased to be up-to-date on the fly.
Debugging with lazy evaluation.
Since evalcache only performs computations when the object is actually requested, and not when it is declared, it can be difficult to understand where a possible error occurs. Problems can also arise due to the implicit expansion of lazy objects on some operations.
The following options can be used to debug and understand where the error occurred:
zencad.lazy.diag=True # Активировать вывод информации об операциях библиотеки кеширования.
zencad.lazy.fastdo=True # Выполнять запрос объекта в момент его создания.
zencad.lazy.encache=False # Запретить сохранение в кэш.
zencad.lazy.decache=False # Запретить загрузку из кэша.
zencad.lazy.onbool=False # Запретить автоматическое раскрытие на булевых операциях
zencad.lazy.onstr=False # Запретить автоматическое раскрытие при преобразовании к строке.
zencad.lazy.onplace=True # Раскрывать объект в момент его создания (не рекомендуется, может нарушать логику).
Additional options can be found in the documentation for the evalcache library code.
Where is the cache?
By default, the cache is located at the local address ~/.zencadcache
, where ~ is the user's home directory.