This is how SmalltyPy works

SmalltyPy was developed for VisualWorks 64-bit and uses a normal development installation of Python as available on the website for Windows, MacOS and Linux.

By using the Python-DLL in SmalltyPy via  DLLCConnect the Python and Smalltalk-Objects are in the same process. Both are sharing the same storage space and enable direct access to each other. This is why any marshalling is not needed in most cases and message-sends or function invocations as well as access to instance variable or attributes are executed with the high speed that the C-interface provides.

SmalltyPy Architecture

The 'Object Buffer' created and managed by SmalltyPy allows VisualWorks applications to access Python classes and instances. That way new Python objects may be created and their functions can be called.

SmalltyPy Instance

Examples and screenshots

Execution of a Python script in a VisualWorks method:

SmalltyPy Script Execution

Execution of Python functions in a VisualWorks method:

Call of Python Method in Smalltalk

The next example prepares the data in VisualWorks and performs the graph calculations with matplotlib in Python, which then may be further processed or displayed in Smalltalk:

Graphics calculation codeGrafik

SmalltyPy allows the integration of Python objects into the VisualWork by allowing to write complete Python classes and functions in VisualWorks, which are accessible to VisualWorks and are execute in Python.

SmalltyPy Classes

A syntax analysis is performed while editing a Python function in the SystemBrowser :

Syntax analysis

Implemented Python functions can be optimized by adding type information and then using the Numba library for optimization; this allows the entire class to be "jitted" (compiled to machine code), thus increasing execution speed. Infrastructures supported by Python to run Python application code in multiple OS threads (CPU or GPU supported) can therefore also be used by VisualWorks.

Object Display

The SmalltyPy environment supports display and analysis of Python objects in the Inspector, it shows the available attributes and functions including extended type information. The Inspector works exactly like the Inspector for Smalltalk objects - the individual attribute slots can be inspected as usual via "drill down".