print(fmt, *args, **kwargs)[source]

A qjit() compatible print function for printing values at runtime.

This print function allows printing of values at runtime, unlike usage of standard Python print which will print values at program capture/compile time.

debug.print is a minimal wrapper around callback() which calls Python’s builtins.print function, and thus will use the same formatting styles as Python’s built-in print function.

  • fmt (str) – The string to be printed. Note that this may also be a format string used to format input arguments (for example cost={x}), similar to those permitted by str.format. See the Python docs on string formatting and format string syntax.

  • **args – Arguments to be passed to the format string.

  • **kwargs – Keyword arguments to be passed to the format string.


>>> @qjit
... def f(a, b, c):
...     debug.print("c={c} b={b} a={a}", a=a, b=b, c=c)
>>> f(1, 2, 3)
c=3 b=2 a=1

In addition to passing keyword arguments to the format string, we can also pass arguments positionally:

>>> @qjit
... def f(x, y):
...     debug.print("Value of x = {0:.2f}", x)
>>> f(0.543, 0.23)
Value of x = 0.54


Using Python f-strings as the fmt string will not work as expected since they will be treated as Python objects.

This means that array values embedded in them will have their compile-time representation printed, instead of actual data.