Skip to main content

Lisp interpreter for user-scriptable server-side applications

Project description

NOT YET SUITABLE FOR PUBLIC USE

Parthial

Parthial is a simple Python implementation of a generic Lisp interpreter. It is intended for use in user-scriptable server-side applications such as IRC bots.

Features

Safe evaluation

Evaluation puts (configurably) strict limitations on recursion depth, number of allocated values, and number of steps taken. The set built-in cannot mutate parent scopes (so closures are immutable), and every other language feature available in the package is purely functional.

Simple API

Lisp values are represented by directly analogous Python objects; (a b c) is just LispList([LispSymbol('a'), LispSymbol('b'), LispSymbol('c')]). It’s easy to define new built-ins, too:

# part of the default_globals scope
# suppresses evaluation of its arguments (quotes them)
@built_in(default_globals, 'if', quotes=True)
def lisp_if(self, ctx, cond, i, t):
    cond = ctx.eval(cond)
    if cond:
        return ctx.eval(i)
    else:
        return ctx.eval(t)

Serialization

PyYAML serializers and deserializers are provided for all Lisp value types, as well as for definition environments (built-ins are serialized by name, so a global scope must be supplied at deserialization). Allocation limitations are kept track of across serializtion, so it’s safe and easy to give users a persistent mutable environment.

Shortcomings

No optimizations

Parthial is not a general-purpose interpreter. There is no compilation or optimization. It probably shouldn’t be used to run any program that wouldn’t be appropriate, performance-wise, to implement as a shell script.

No code reviews (yet)

Nobody other than the original author has looked the code yet. For now, it’d be unwise to actually expose an interpreter to the Internet at large, in case of security holes.

No[t much] documentation (so far)

Working on it…

No tests (for now)

The warning at the top is there for a reason.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

parthial-0.2.2-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file parthial-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for parthial-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cd8e4866b3622da7aa2196889dfbcc4124dfce45724a2a3606d8443b88abeea0
MD5 9e75ad410c2c6612546cb56a25649b53
BLAKE2b-256 48c2d62dbb2f86ed8f980c67471841986421eeab7c353006e78eeb4936448c6c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page