The simplest way to invoke custom Python code from a toplevel VentureScript program are the pyexec and pyeval inference actions (which see).
For more elaborate integrations, one can write a plugin. In a plugin, one can
A Venture plugin is just a Python module that defines a toplevel function called __venture_start__.
Any of these will load the plugin in the given file, and call its __venture_start__ function with one argument, namely the Ripl object representing the current Venture session. The plugin is then free to invoke what methods it will on that Ripl.
If extra arguments are passed to either the ripl method load_plugin or the inference action load_plugin, those will be forwarded to the plugin’s __venture_start__ function. If __venture_start__ returns a value, that value will be returned by load_plugin. There is currently no way to pass arguments to a plugin loaded from the command line, nor to capture any value that it might return.
Useful ripl methods to call from a plugin’s __venture_start__:
Print the time that has elapsed since the timer was started by timer_start.
Resume a timer paused by timer_pause.
Start a timer.
Resets any currently running timer that was started using timer_start.
Pause the timer started by timer_start.
This is mainly for cumulative measurements (e.g. benchmarking) where some sections should be excluded.