swiplserver
Note that swiplserver 1.0 changes the names of classes from previous versions in an incompatible way -- the terminology changed from 'language server' to 'machine query interface (MQI)'. You'll need to update your code as you transition. The names should be stable from version 1.0 on, however.
The swiplserver module provides a set of classes to call SWI Prolog from Python. It allows running any query from Python that could be executed from the SWI Prolog console (i.e. the "top level"). Answers to Prolog queries are returned as JSON.
The library uses a SWI Prolog interface called the Machine Query Interface ('MQI') that allows Prolog queries to be executed. It also manages launching and shutting down SWI Prolog automatically, making the process management invisible to the developer. The whole experience should feel just like using any other library.
from swiplserver import PrologMQI, PrologThread
with PrologMQI() as mqi:
with mqi.create_thread() as prolog_thread:
result = prolog_thread.query("member(X, [color(blue), color(red)])")
print(result)
[{'X': {'functor': 'color', 'args': ['blue']}},
{'X': {'functor': 'color', 'args': ['red']}}]
To install and learn how to use the swiplserver Python library, see the docs.
Supported Configurations
Should work on:
- MQI protocol version 1.x or prior
- SWI Prolog 8.2.2 or greater (may work on older builds, untested)
- Any Mac, Linux Variants or Windows that are supported by SWI Prolog
- Python 3.7 or later (may work on older builds, untested)
Has been tested with:
- Ubuntu 20.04.2 + SWI Prolog 8.3.22 + Python 3.7.8
- Windows 10 Pro 64 bit + SWI Prolog 8.3.27 + Python 3.7.0
- Windows 8.1 Pro 64 bit + SWI Prolog 8.2.4 + Python 3.8.1
- MacOS Catalina/Big Sur + SWI Prolog 8.3.24 + Python 3.7.4
Performance
If you're interested in rough performance overhead of the approach this library takes. On a late 2013 macbook pro the per call overhead of the library for running a Prolog query is about:
- 170 uSec per call using TCP/IP localhost
- 145 uSec per call using Unix Domain Sockets
Metadata
Release files for swiplserver 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| swiplserver-1.0.2.tar.gz | 18.3 kB | Without provenance | Details for swiplserver-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| swiplserver-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for swiplserver-1.0.2-py3-none-any.whl |
Total release size: 36.4 kB
Release files / swiplserver-1.0.2.tar.gz
| Download URL | swiplserver-1.0.2.tar.gz |
|---|---|
| Size | 18.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
42e2fae197c1200bb102cba9b186a86ad0ffd224e867bc9cb6b98b66399263b5
|
|
BLAKE2b-256 checksum How to use checksums |
b9a083869dfb2d59a19a81555f78349b3f9615343f14cb70b2a10853ded81af9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9
|
Release files / swiplserver-1.0.2-py3-none-any.whl
| Download URL | swiplserver-1.0.2-py3-none-any.whl |
|---|---|
| Size | 18.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f83460dc8afa205d4014a6ea1265154749ffce0167e466b51f18d81f5d51e750
|
|
BLAKE2b-256 checksum How to use checksums |
8e84d0c055a1d322003d1eaa92ae6fccc0608ec08807a2943897c006d26299e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9
|
Security for swiplserver 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.