Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

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


Release history Release notifications

This version
History Node

0.2.2

History Node

0.2.1

History Node

0.2

History Node

0.1

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
parthial-0.2.2-py3-none-any.whl (11.3 kB) Copy SHA256 hash SHA256 Wheel py3 Mar 27, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page