Did you know ... Search Documentation:
News

Janus provides a bi-directional interface to Python

0 upvotes 0 0 downvotes
Picture of user Jan Wielemaker.

The new Janus package allows embedding Python into SWI-Prolog as well as SWI-Prolog into Python. It provides a bi-directional interface with a high level mapping between the dynamically typed data of both systems. Prolog calls Python using py_call/2 or py_iter/2 to backtrack over a Python iterator or generator. Python can use janus.once() to cal a predicate as once/1 while janus.Query() implements a Python iterator from a non-deterministic Prolog predicate.

Janus comes as a Prolog library (embedding Python in Prolog) and a Python package for embedding Prolog in Python. After loading either way, the interface fully equivalent.

The library provides excellent performance, transferring a list of 1M integers in less than 0.1 second, allow Prolog to call Python functions and methods at about 1M calls per second and Python calling Prolog at about 0.5M calls per second.

Janus was created by Theresa Swift and Carl Anderson for XSB. The two implementations are independent. We are close to agreeing on a common subset that will work on both implementations such that we can develop libraries that exploit Python that are portable across systems that provide Janus.

SWEEP: A SWI-Prolog mode for GNU-Emacs based on semantic analysis by Prolog

1 upvotes 1 0 downvotes
Picture of user Jan Wielemaker.

Good editing support for Prolog is hard due to the lack of keywords, types and homoiconicity (code is data). This was the motivation for the built-in PceEmacs clone that is written in Prolog and allows for direct interaction with the editor buffer from Prolog: reading, writing and controlling syntax highlighting.

Eshel Yaron wrote sweep which embeds SWI-Prolog as a module in GNU-Emacs, providing similar possibilities. The required foreign extension module is part of the binary distributions for SWI-Prolog in recent development releases and will be part of SWI-Prolog 9.x that will be released soon.

The mode is under active development. In its current state it is already much better than any previous Emacs mode for Prolog. It still lacks a few features wrt. PceEmacs, but it also comes with a lot of goodies compared to PceEmacs.

See also
- https://eshelyaron.com/sweep.html