SWI-Prolog Python interface
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog Python interface
        • Introduction
        • Data conversion
        • Janus by example - Prolog calling Python
        • library(janus): Call Python from Prolog
        • Calling Prolog from Python
        • Janus and threads
        • Janus and signals
        • Janus versions
        • Janus as a Python package
        • Prolog and Python
        • Janus performance evaluation
        • Python or C/C++ for accessing resources?
        • Janus platforms notes
        • Compatibility to the XSB Janus implementation
        • Status of Janus

11 Janus performance evaluation

Below is a table to give some feeling on the overhead of making calls between Prolog and Python. These figures are roughly the same as the figures for the XSB/Python interface. All benchmarks have been executed on AMD3950X running Ubuntu 22.04, SWI-Prolog 9.1.11 and Python 3.10.6.

Action Time (seconds)
Echo list with 1,000,000 elements0.12
Call Pyton demo:int() from Prolog 1,000,000 times0.44
Call Pyton demo:sumlist3(5,[1,2,3]) from Prolog 1,000,000 times1.4
Call Prolog Y is X+1 from Python 1,000,000 times1.9
Iterate from Python over Prolog goal between(1, 1 000 000, X) 1.1
Iterate over Python iterator range(1,1000000) from Prolog0.17