This documentation may be out of date. See the latest version.

Tooling Support for Python

GraalVM Python runtime can run many standard Python tools as well as tools from the GraalVM ecosystem. The graalpy --help:tools command will give you more information about GraalVM tools currently supported on Python.

Debugger #

The built-in breakpoint() function will use pdb by default.


The standard python debugger pdb is supported on GraalVM. Refer to the offical PDB documentation for usage.

Chrome Inspector #

To enable GraalVM’s Chrome Inspector debugger, pass the --inspect option to the graalpy launcher. The built-in breakpoint() function will work using the Chrome Inspector implementation when --inspect is passed.

Code Coverage #

GraalVM comes with a coverage instrument that can be used with --coverage. Use the graalpy --help:tools command to see details on how to use it.

In order to work better with existing Python code, the standard library trace module is partially supported with this low-overhead GraalVM coverage instrument. So you can do this:

graalpy -m trace -m -c -s

This will work similarly to how it would run on CPython.

The programmatic API also works, with some limitations. For example, it does not currently track calls, only line counts and called functions.

Profiling #

The _lsprof built-in module has been implemented using the GraalVM cpusampler tool. Not all profiling features are currently supported, but basic profiling works:

graalpy -m cProfile -s calls -m ginstall --help

The interactive exploration of a stats output file also works:

graalpy -m cProfile -o ginstall.profile -m ginstall --help
graalpy -m pstats ginstall.profile

The profile module works as well:

graalpy -m profile -s calls -m ginstall --help


>>> import profile
>>>'l = []; l.append(1)')
         5 function calls in 0.002 seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.000    0.000 :0(_setprofile)
        1    0.000    0.000    0.000    0.000 :0(append)
        1    0.000    0.000    0.001    0.001 :0(exec)
        1    0.000    0.000    0.000    0.000 <string>:1(<module>)
        1    0.001    0.001    0.002    0.002 profile:0(l = []; l.append(1))
        0    0.000             0.000          profile:0(profiler)

Connect with us