An implementation of Python in Common Lisp

Overview

CLPython - an implementation of Python in Common Lisp

CLPython is an open-source implementation of Python written in Common Lisp. With CLPython you can run Python programs in a Lisp environment. Libraries written in Lisp are available to Python code, and Python libraries can be accessed by Lisp code. Also Python and Lisp code can be mixed.

For rough documentation, please see the Introduction and Manual on common-lisp.net.

To install using QuickLisp: (ql:quickload "clpython") (require ASDF 3.3 or higher).

CLPython is developed by Willem Broekema and is released as open source under the LLGPL. The project was started in 2006, and is since 2013 not under active development anymore.

See the build status on Travis-CI, and the coverage status on Coveralls:

Common Lisp Implementation Build + Test Status
ABCL 1.5.0 Build Status Fails due to ClassCastException: StandardObject cannot be cast to LispClass
Allegro CL 10.1 Build Status
Clozure CL 1.11 Build Status
CLISP 2.49 Build Status Fails due to stack overflow
CMUCL ?
ECL 16.1.3 Build Status
LispWorks 6.1.1 Manually verified
SBCL 1.5.4 Build Status Coverage Status
Comments
  • does not load in LispWorks 7.1.1

    does not load in LispWorks 7.1.1

    CL-USER 1 > (ql:quickload "clpython")
    ...
    **++++ Error in (DEFCLASS CLPYTHON:PY-TYPE): 
      #<STANDARD-CLASS DICT-MIXIN 40200E136B> is an invalid superclass of #<PY-META-TYPE PY-TYPE 402013771B>.
    
    opened by lispm 3
  • Cannot import CL packages under recent SBCL

    Cannot import CL packages under recent SBCL

    The following file cannot be loaded with clpython:run on recent versions of SBCL:

    import CL
    CL.PRINT("FOO")
    

    Tested as failing on 1.4.13 and likely starting with the ASDF update in 1.4.2. Here is the backtrace:

    ImportError: Loading of module `CL' was aborted. Binary: /tmp/user/1000/clpython-cl-fasl-p6tnmpa2Imported by: /home/ntd/git/tmkit/test.py
    
    1: ((FLET CLPYTHON::LOG-ABORT :IN CLPYTHON::PY-IMPORT) T)
    2: ((FLET "CLEANUP-FUN-54" :IN CLPYTHON::PY-IMPORT)) [cleanup]
    3: (CLPYTHON::PY-IMPORT (CLPYTHON.USER::CL) :WITHIN-MOD-PATH #P"/home/ntd/git/tmkit/test.py" :WITHIN-MOD-NAME "__main__")
    4: (CLPYTHON::|python-module __main__|)
    5: (CLPYTHON.USER::|{__main__[0] "import CL" #4138581656636548740}| #<HASH-TABLE :TEST EQ :COUNT 2 {100343ACE3}>)
    6: ((FLET CLPYTHON::RUN-TOP-LEVEL-FORMS :IN CLPYTHON::MODULE-INIT) #<HASH-TABLE :TEST EQ :COUNT 2 {100343ACE3}>)
    7: ((FLET CLPYTHON:RUN :IN CLPYTHON:RUN-PYTHON-AST))
    

    The issue appears to arise in CLPYTHON::COMPILED-FILE-NAME with the call to (make-instance 'asdf:compile-op). On newer SBCL, this throws the following error:

    OPERATION instances must only be created through MAKE-OPERATION.
    

    Replacing cl:make-instance with asdf:make-operation does not throw the error in COMPILED-FILE-NAME and the above CL import works on SBCL 1.4.13 and 1.3.14

    opened by ndantam 2
  • BREAK is unfriendly, why not use ERROR or SIGNAL?

    BREAK is unfriendly, why not use ERROR or SIGNAL?

    cl-pythong source code uses BREAK several in several places.

    It's inconvenient. For example, when I do (ql:quickload :clpython) on ABCL when testing libraries with cl-test-grid, clpython calls BREAK with message "A CHECKING-READER-CONDITIONALS expression returned zero forms: (CLPYTHON.UTIL:CHECKING-READER-CONDITIONALS)".

    The ABCL process remains hanging, I can't capture this situation programmatically.

    It it was ERROR instead of BREAK, test-grig-agent could intercept it using either HANDLER-BIND or DEBUGGER-HOOK and record error.

    opened by avodonosov 2
  • quickload clpython fails on Lispworks 6.1.1 (32-bit) Mac OS X 10.8 (64-bit)

    quickload clpython fails on Lispworks 6.1.1 (32-bit) Mac OS X 10.8 (64-bit)

    When I do (ql:quickload "clpython") fails with the following:

    Error: Symbol "OPEN-TEMPORARY" not found at all in the CL-FAD package. 1 (continue) Make a new symbol. 2 Try reading the next form. 3 Try compiling /Users/deepaksurti/quicklisp/dists/quicklisp/software/cl-python-20140211-git/runtime/import.lisp again. 4 Skip compiling /Users/deepaksurti/quicklisp/dists/quicklisp/software/cl-python-20140211-git/runtime/import.lisp. 5 Retry compiling #<ASDF:CL-SOURCE-FILE "clpython.runtime" "runtime" "import">. 6 Continue, treating compiling #<ASDF:CL-SOURCE-FILE "clpython.runtime" "runtime" "import"> as having been successful. 7 (abort) Give up on "clpython" 8 Return to level 0. 9 Return to top-level loop. 10 Return from multiprocessing.

    Is it related to https://github.com/metawilm/cl-python/issues/9?

    opened by dmsurti 2
  • ql:quickload

    ql:quickload "clpython" fails in Lispworks 6.1.1 on Ubuntu

    After ql:quickload "clpython", the packages were downloaded and they began to be processed:

    ... [package clpython.module]......................... [package clpython]................................ [package clpython.app.repl]...... Error: No translations for logical pathname host "TEMPORARY-FILES". 1 (continue) Try loading /home/caldwell/.cache/common-lisp/lw-6.1.1-linux-x64/home/caldwell/quicklisp/dists/quicklisp/software/temporary-file-20120909-git/temporary-file.64ufasl again. ...

    opened by jdcal 2
  • Compilation doesn't seem to matter, performance-wise, when running pystone.py

    Compilation doesn't seem to matter, performance-wise, when running pystone.py

    Roughly:

    • (CLPYTHON:RUN #p"/usr/lib/python2.6/test/pystone.py" :compile nil :args '("pystone.py" "1000000")) Pystone(1.1) time for 1000000 passes = 28.630005
      This machine benchmarks at 34928.39 pystones/second
    • (CLPYTHON:RUN #p"/usr/lib/python2.6/test/pystone.py" :compile t :args '("pystone.py" "1000000")) Pystone(1.1) time for 1000000 passes = 29.440002
      This machine benchmarks at 33967.387 pystones/second

    As a contrast, this machine marks at roughly 90000 pystones with cpython 2.6.

    opened by deepfire 2
  • Unfix ECL

    Unfix ECL

    Upcoming ECL release will have this problem solved (and clpython does not load with this fix present, because class is not available at compile time).

    opened by dkochmanski 1
  • generator function unknown

    generator function unknown

    (defun |tee| (iterable &optional (n 2))
      "Create N independent generators"
      (check-type n integer)
      (cond ((zerop n)
             (make-tuple-from-list ()))
            (t
             (let ((iter-func (clpython::get-py-iterate-fun iterable))
                   (deques (loop repeat n collect (clpython.module._collections:|deque|))))
               (flet ((generator (deque)
                        (clpython::make-iterator-from-function
                         :name :tee-iterator
                         :func (lambda () 
                                 (if (clpython::py-val->lisp-bool deque)
                                     (clpython.module._collections::deque.popleft deque)
                                   (let ((new-val (funcall iter-func)))
                                     ;; also continue if NEW-VAL is NIL
                                     (dolist (d deques)
                                       (unless (eq d deque)
                                         (clpython.module._collections::deque.append d new-val)))
                                     new-val))))))
                 (make-tuple-from-list (mapcar 'generator deques)))))))
    

    Probably the MAPCAR should use #'generator and not 'generator

    opened by lispm 1
  • Do not derive pathname of module source

    Do not derive pathname of module source

    In reference to issue https://github.com/metawilm/cl-python/issues/1, I was still unable to load python files with mixed case on SBCL. CLPYTHON:PARSE works fine on the mixed-case pathname and just calls SLURP-FILE on the provided pathname. I can then call CLPYTHON:RUN-PYTHON-AST on the parsed AST.

    However, giving the pathname to CLPYTHON:RUN would result in an additional call to SLURP-FILE during macroexpansion of [MODULE-STMT]. In [MODULE-STMT], the pathname is reinterpreted through DERIVE-PATHNAME, which on SBCL alters the provided case. Removing the call to DERIVE-PATHNAME in [MODULE-STMT] appears to workaround this issue.

    opened by ndantam 1
  • Metadata for Quicklisp

    Metadata for Quicklisp

    Please consider adding :description, :author and :license information to your ASDF system(s). This will greatly help Quicklisp users and make it easier for them to report bugs.

    More information:

    http://blog.quicklisp.org/2015/05/looking-for-more-metadata.html https://www.quicklisp.org

    opened by hydandata 1
  • Added more grammar support for import statements

    Added more grammar support for import statements

    Hey,

    I have been playing around with the grammar for cl-python trying to get to more compatable with the python 2.7.5 grammar. This is an extension of the existing import grammar that will allow trailing commas.

    from sys import (path, argv,)
    

    I have been having some problems getting the test cases to re-compile as expected. I seem to have to quickload the whole clpython.test to actually get correct results after i have had one failed run. Otherewise it seems to report the same failure over and over.

    Thanks, Russell

    opened by russell 1
  • importing library types fails

    importing library types fails

    When attempting to load the library bdb, it fails with the following error

    There is no applicable method for the generic function
      #<STANDARD-GENERIC-FUNCTION CLPYTHON::PY-FUNCTION-CODE (1)>
    when called with arguments
      (#<FUNCTION # {10100EF89B}>).
       [Condition of type SIMPLE-ERROR]
    

    After loading the latest HEAD from github with ql:quickload (by placing the repo in ~/quicklisp/local-projects), I run the following to produce this error

    CL-USER> (clpython.app.repl:repl)
    Welcome to CLPython, an implementation of Python in Common Lisp.
    Running on: SBCL 1.1.2.35-2b29a7c
    REPL shortcuts: `:q' = quit, `:h' = help.
    
    ;; Consider customizing variable *CLPYTHON-MODULE-SEARCH-PATHS*
    ;; to be a list of paths that are tried when locating a module in order to import it
    ;; (in addition to the current directory and `sys.path'). Typically it should at least
    ;; contain the path to the Python (2.5) standard libraries, as those are not
    ;; distributed with CLPython.
    >>> import sys
    #<module SYS (package "CLPYTHON.MODULE.SYS" with 41 external symbols) {10044C1113}>
    >>> print sys.path
    [.]
    >>> sys.path = ['/usr/lib/python2.7/']
    
    [/usr/lib/python2.7/]
    >>> import bdb
    ;; Parsing #P"/usr/lib/python2.7/bdb.py" into #P"/tmp/clpython-bdb-lisp-58ac5use"
    ;; Parsing #P"/usr/lib/python2.7/fnmatch.py" into #P"/tmp/clpython-fnmatch-lisp-gfao9rlf"
    ;; Parsing #P"/usr/lib/python2.7/os.py" into #P"/tmp/clpython-os-lisp-bcztmntz"
    ;; Parsing #P"/usr/lib/python2.7/posixpath.py" into #P"/tmp/clpython-posixpath-lisp-v3d8ocj1"
    ;; Parsing #P"/usr/lib/python2.7/stat.py" into #P"/tmp/clpython-stat-lisp-hm7j90p1"
    ;; Parsing #P"/usr/lib/python2.7/genericpath.py" into #P"/tmp/clpython-genericpath-lisp-uiuj8gke"
    ;; Parsing #P"/usr/lib/python2.7/warnings.py" into #P"/tmp/clpython-warnings-lisp-u1dmflid"
    ;; Parsing #P"/usr/lib/python2.7/linecache.py" into #P"/tmp/clpython-linecache-lisp-qjgoy79x"
    ;; Parsing #P"/usr/lib/python2.7/types.py" into #P"/tmp/clpython-types-lisp-2mfjlxbg"
    

    Let me know if there's any other information I can provide to help with this.

    opened by futuro 2
Owner
Willem Broekema
Graph database query engines. Sousaphone & Swing. "Triple steps and triple stores"
Willem Broekema
DO NOT USE. Implementation of Python 3.x for .NET Framework that is built on top of the Dynamic Language Runtime.

IronPython 3 IronPython3 is NOT ready for use yet. There is still much that needs to be done to support Python 3.x. We are working on it, albeit slowl

IronLanguages 2k Dec 30, 2022
MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems

The MicroPython project This is the MicroPython project, which aims to put an implementation of Python 3.x on microcontrollers and small embedded syst

MicroPython 15.7k Dec 31, 2022
A faster and highly-compatible implementation of the Python programming language. The code here is out of date, please follow our blog

Pyston is a faster and highly-compatible implementation of the Python programming language. Version 2 is currently closed source, but you can find the

null 4.9k Dec 21, 2022
A mini implementation of python library.

minipy author = RQDYSGN date = 2021.10.11 version = 0.2 1. 简介 基于python3.7环境,通过py原生库和leetcode上的一些习题构建的超小型py lib。 2. 环境 Python 3.7 2. 结构 ${project_name}

RQDYGSN 2 Oct 26, 2021
A faster and highly-compatible implementation of the Python programming language.

Pyston Pyston is a fork of CPython 3.8.8 with additional optimizations for performance. It is targeted at large real-world applications such as web se

null 2.3k Jan 9, 2023
The Python programming language

This is Python version 3.10.0 alpha 5 Copyright (c) 2001-2021 Python Software Foundation. All rights reserved. See the end of this file for further co

Python 49.7k Dec 30, 2022
Grumpy is a Python to Go source code transcompiler and runtime.

Grumpy: Go running Python Overview Grumpy is a Python to Go source code transcompiler and runtime that is intended to be a near drop-in replacement fo

Google 10.6k Dec 24, 2022
x86-64 assembler embedded in Python

Portable Efficient Assembly Code-generator in Higher-level Python (PeachPy) PeachPy is a Python framework for writing high-performance assembly kernel

Marat Dukhan 1.7k Jan 3, 2023
Pyjion - A JIT for Python based upon CoreCLR

Pyjion Designing a JIT API for CPython A note on development Development has moved to https://github.com/tonybaloney/Pyjion FAQ What are the goals of

Microsoft 1.6k Dec 30, 2022
The Stackless Python programming language

This is Python version 3.7.0 alpha 4+ Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 20

Stackless Python 891 Jan 3, 2023
Rust syntax and lexical analyzer implemented in Python.

Rust Scanner Rust syntax and lexical analyzer implemented in Python. This project was made for the Programming Languages class at ESPOL (SOFG1009). Me

Joangie Marquez 0 Jul 3, 2022
Core Python libraries ported to MicroPython

This is a repository of libraries designed to be useful for writing MicroPython applications.

MicroPython 1.8k Jan 7, 2023
Github timeline htmx based web app rewritten from Common Lisp to Python FastAPI

python-fastapi-github-timeline Rewrite of Common Lisp htmx app _cl-github-timeline into Python using FastAPI. This project tries to prove, that with h

Jan Vlčinský 4 Mar 25, 2022
Really bad lisp implementation. Fun with pattern matching.

Lisp-py This is a horrible, ugly interpreter for a trivial lisp. Don't use it. It was written as an excuse to mess around with the new pattern matchin

Erik Derohanian 1 Nov 23, 2021
A 3-line lisp implementation

Nanolisp The download page of many a language harbors deep senses of forboding, of evil lurking in its native lair. You feel that the language is not

null 5 Jun 17, 2022
Compiler Final Project - Lisp Interpreter

Compiler Final Project - Lisp Interpreter

null 2 Jan 23, 2022
Compute distance between sequences. 30+ algorithms, pure python implementation, common interface, optional external libs usage.

TextDistance TextDistance -- python library for comparing distance between two or more sequences by many algorithms. Features: 30+ algorithms Pure pyt

Life4 3k Jan 2, 2023
Compute distance between sequences. 30+ algorithms, pure python implementation, common interface, optional external libs usage.

TextDistance TextDistance -- python library for comparing distance between two or more sequences by many algorithms. Features: 30+ algorithms Pure pyt

Life4 3k Jan 6, 2023
Compute distance between sequences. 30+ algorithms, pure python implementation, common interface, optional external libs usage.

TextDistance TextDistance -- python library for comparing distance between two or more sequences by many algorithms. Features: 30+ algorithms Pure pyt

Life4 1.9k Feb 18, 2021