Question
Fred Gustafsson · Sep 8

Information about how Python integration works technically

I'm after some more in-depth information about how the embedded python is implemented with regards to how it works when a python method is called from a CSP page. Will it run in the same Windows process? Will there be any issues with multitasking (considering python doesn't seem very good at this)?

Also, is there a performance penalty to pay for running embedded python vs "using IRIS APIs from Python". 

Another question is what python interpreter the embedded python is using? Is it an Intersystems one or the regular c.python? Version?

Excited to go Python!

Product version: IRIS 2022.1
0
0 189
Discussion (2)2
Log in or sign up to continue

Glad to hear the interest in Python.

When you use embedded python, IRIS loads Python into memory in the process (via CPython).  The specific version of Python depends on your OS.  That's documented here:  https://docs.intersystems.com/irisforhealthlatest/csp/docbook/DocBook.UI...

Loading Python into the IRIS process does just what you think it does - not a separate process and references in Python to ObjectScript objects are in-memory.  So there's no performance difference between using Embedded Python from IRIS or starting with a Python program and `import iris`.

Will it run in the same Windows process?

Yes.

Will there be any issues with multitasking (considering python doesn't seem very good at this)?

GIL still exists and applies. If you write async code it would only be executed while control flow is on a python side of things. You can't spawn async task in python, go to InterSystems ObjectScript to do something else and then come to a completed python task.

Also, is there a performance penalty to pay for running embedded python vs "using IRIS APIs from Python". 

IRIS APIs from Python (Native SDK/Native API) can be invoked either in-shared-memory or over TCP. TCP comes with a performance penalty.

Another question is what python interpreter the embedded python is using? Is it an Intersystems one or the regular c.python?

CPython.

Version?

Use sys.version to check. Recently it was Python 3.9.5 on Windows and 3.8.10 on Linux.