The py4cl2 Reference Manual

This is the py4cl2 Reference Manual, version 2.9.3, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 08 19:15:20 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 py4cl2

Some improvements over py4cl. py4cl is a library for interfacing with python libraries from common lisp, using streams to communicate with the python process. Report the issues at https://github.com/digikar99/py4cl2/issues
(More) Documentation is available at https://digikar99.github.io/py4cl2/

License

MIT

Version

2.9.3

Dependencies
  • alexandria (system).
  • bordeaux-threads (system).
  • cl-json (system).
  • float-features (system).
  • iterate (system).
  • numpy-file-format (system).
  • parse-number (system).
  • trivial-garbage (system).
  • uiop (system).
Source

py4cl2.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 py4cl2/py4cl2.asd

Source

py4cl2.asd.

Parent Component

py4cl2 (system).

ASDF Systems

py4cl2.


3.1.2 py4cl2/package.lisp

Dependency

python-code (file).

Source

py4cl2.asd.

Parent Component

py4cl2 (system).

Packages

py4cl2.


3.1.3 py4cl2/config.lisp

Dependency

package.lisp (file).

Source

py4cl2.asd.

Parent Component

py4cl2 (system).

Public Interface
Internals

3.1.4 py4cl2/features.lisp

Dependencies
Source

py4cl2.asd.

Parent Component

py4cl2 (system).

Public Interface
Internals

3.1.5 py4cl2/python-process.lisp

Dependencies
Source

py4cl2.asd.

Parent Component

py4cl2 (system).

Public Interface
Internals

3.1.6 py4cl2/reader.lisp

Dependencies
Source

py4cl2.asd.

Parent Component

py4cl2 (system).

Public Interface
Internals

3.1.7 py4cl2/writer.lisp

Dependencies
Source

py4cl2.asd.

Parent Component

py4cl2 (system).

Public Interface

pythonize (generic function).

Internals

3.1.8 py4cl2/lisp-classes.lisp

Dependencies
Source

py4cl2.asd.

Parent Component

py4cl2 (system).

Public Interface

3.1.9 py4cl2/callpython.lisp

Dependencies
Source

py4cl2.asd.

Parent Component

py4cl2 (system).

Public Interface
Internals

3.1.10 py4cl2/arg-list.lisp

Dependencies
Source

py4cl2.asd.

Parent Component

py4cl2 (system).

Internals

3.1.11 py4cl2/import-export.lisp

Dependencies
Source

py4cl2.asd.

Parent Component

py4cl2 (system).

Public Interface
Internals

3.1.12 py4cl2/do-after-load.lisp

Dependency

import-export.lisp (file).

Source

py4cl2.asd.

Parent Component

py4cl2 (system).


3.2 Static


3.2.1 py4cl2/python-code

Source

py4cl2.asd.

Parent Component

py4cl2 (system).


3.2.2 py4cl2/.config

Dependency

do-after-load.lisp (file).

Source

py4cl2.asd.

Parent Component

py4cl2 (system).


4 Packages

Packages are listed by definition order.


4.1 py4cl2

Source

package.lisp.

Use List
  • alexandria.
  • common-lisp.
  • iterate.
Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Special variables

Special Variable: *additional-init-codes*

A list of strings each of which should be python code. All the code
will be executed by PYSTART. The code should not contain single-quotation marks.

Package

py4cl2.

Source

python-process.lisp.

Special Variable: *config*

Configuration variable used to store configuration values for PY4CL2. This variable should be manipulated using CONFIG-VAR and (SETF CONFIG-VAR).

Package

py4cl2.

Source

config.lisp.

Special Variable: *defpymodule-silent-p*

DEFPYMODULE avoids printing progress if this is T.

Package

py4cl2.

Source

import-export.lisp.

Special Variable: *internal-features*

A list of PY4CL2 features available on the system. (Support for :ARRAYS requires numpy and is only determinable after python process has started.)

The list can include one or more of:

:WITH-PYTHON-OUTPUT
:TYPED-ARRAYS
:FAST-LARGE-ARRAY-TRANSFER
:INTERRUPT

Package

py4cl2.

Source

features.lisp.

Special Variable: *lispifiers*

Each entry in the alist *LISPIFIERS* maps from a lisp-type to
a single-argument lisp function. This function takes as input the "default" lisp objects and is expected to appropriately parse it to the corresponding lisp object.

NOTE: This is a new feature and hence unstable; recommended to avoid in production code.

Package

py4cl2.

Source

config.lisp.

Special Variable: *print-python-object*

If non-NIL, python’s ’str’ is called on the python-object before printing.

Package

py4cl2.

Source

reader.lisp.

Special Variable: *pythonizers*

Each entry in the alist *PYTHONIZERS* maps from a lisp-type to
a single-argument PYTHON-FUNCTION-DESIGNATOR. This python function takes as input the "default" python objects and is expected to appropriately convert it to the corresponding python object.

NOTE: This is a new feature and hence unstable; recommended to avoid in production code.

Package

py4cl2.

Source

config.lisp.

Special Variable: *warn-on-unavailable-feature-usage*

If non-NIL, then issues a WARNING on use of a feature unavailable on the platform. See PY4CL2:*INTERNAL-FEATURES* for the list of available features.

Package

py4cl2.

Source

features.lisp.


5.1.2 Macros

Macro: chain (&rest chain)
Package

py4cl2.

Source

callpython.lisp.

Macro: defpyfun (fun-name &optional pymodule-name &key as cache lisp-fun-name lisp-package safety)

Defines a function which calls python
Example
(py4cl:pyexec "import math")
(py4cl:defpyfun "math.sqrt")
(math.sqrt 42) -> 6.4807405

Arguments:

FUN-NAME: name of the function in python, before import
PYMODULE-NAME: name of the module containing FUN-NAME

AS: name of the function in python, after import
CACHE: if non-NIL, constructs the function body at macroexpansion time LISP-FUN-NAME: name of the lisp symbol to which the function is bound* LISP-PACKAGE: package (not its name) in which LISP-FUN-NAME will be interned SAFETY: if T, adds an additional line in the function asking to import the package or function, so that the function works even after PYSTOP is called. However, this increases the overhead of stream communication, and therefore, can reduce speed.

Package

py4cl2.

Source

import-export.lisp.

Macro: defpyfuns (&rest args)

Each ARG is supposed to be a 2-3 element list of
(pyfun-name pymodule-name) or (pyfun-name pymodule-name lisp-fun-name). In addition, when ARG is a 2-element list, then, the first element can be a list of python function names.

Package

py4cl2.

Source

import-export.lisp.

Macro: defpymodule (pymodule-name &optional import-submodules &key cache continue-ignoring-errors lisp-package reload recompile-on-change safety silent)

Import a python module (and its submodules) as a lisp-package(s).
Example:
(py4cl:defpymodule "math" :lisp-package "M")
(m:sqrt 4) ; => 2.0

Arguments:

PYMODULE-NAME: name of the module in python, before importing
IMPORT-SUBMODULES: leave nil for purposes of speed, if you won’t use the submodules

CACHE: if non-NIL, produces the DEFPACKAGE and DEFUN forms at macroexpansion time to speed-up future reloads of the system
LISP-PACKAGE: lisp package, in which to intern (and export) the callables RECOMPILE-ON-CHANGE: the name of the ASDF system to recompile if the python version of PYMODULE-NAME changes; this only has effect if CACHE is non-NIL
RELOAD: redefine the LISP-PACKAGE if T
SAFETY: value of safety to pass to defpyfun; see defpyfun
SILENT: prints "status" lines when NIL

Package

py4cl2.

Source

import-export.lisp.

Macro: with-lispifiers ((&rest overriding-lispifiers) &body body)

Each entry of OVERRIDING-LISPIFIERS is a two-element list of the form
(TYPE LISPIFIER)
Here, TYPE is unevaluated, while LISPIFIER will be evaluated; the LISPIFIER is expected to take a default-lispified object (see lisp-python types translation table in docs) and return the appropriate object user expects.

For example,

(PYEVAL "[1, 2, 3]") ;=> #(1 2 3) ; the default lispified object
(with-lispifiers ((vector (lambda (x) (coerce (print x) ’list))))
(print (pyeval "[1,2,3]"))
(print (pyeval 5)))
; #(1 2 3) ; default lispified object
; (1 2 3) ; coerced to LIST by the lispifier
; 5 ; lispifier uncalled for non-VECTOR
5

NOTE: This is a new feature and hence unstable; recommended to avoid in production code.

Package

py4cl2.

Source

config.lisp.

Macro: with-python-output (&body forms-decl)

Gets the output of the python program executed in FORMS-DECL in the form a string.

Package

py4cl2.

Source

python-process.lisp.

Macro: with-pythonizers ((&rest overriding-pythonizers) &body body)

Each entry of OVERRIDING-PYTHONIZERS is a two-element list of the form
(TYPE PYTHONIZER)
Here, TYPE is unevaluated, while PYTHONIZER will be evaluated; the PYTHONIZER is expected to take a default-pythonized object (see lisp-python types translation table in docs) and return the appropriate object user expects.

For example,

(pyeval "[1, 2, 3]") ;=> #(1 2 3) ; the default object
(with-pythonizers ((vector "tuple"))
(print (pyeval "[1,2,3]"))
(print (pyeval 5)))
; #(1 2 3) ; default object
; (1 2 3) ; coerced to tuple by the pythonizer, which then translates to list
; 5 ; pythonizer uncalled for non-VECTOR
5

NOTE: This is a new feature and hence unstable; recommended to avoid in production code.

Package

py4cl2.

Source

config.lisp.

Macro: with-remote-objects (&body body)

Ensures that all values returned by python functions
and methods are kept in python, and only handles returned to lisp. This is useful if performing operations on large datasets.

Package

py4cl2.

Source

callpython.lisp.

Macro: with-remote-objects* (&body body)

Ensures that all values returned by python functions
and methods are kept in python, and only handles returned to lisp.
This is useful if performing operations on large datasets. Unlike with-remote-objects, evaluates the last result and returns not just a handle.

Package

py4cl2.

Source

callpython.lisp.


5.1.3 Ordinary functions

Function: chain* (&rest chain)
Package

py4cl2.

Source

callpython.lisp.

Function: (setf chain*) (&rest args)
Package

py4cl2.

Source

callpython.lisp.

Function: config-var (var)

Returns the value associated with VAR in *CONFIG*.
Configuration variables include (all in PY4CL2 package):

- PYCMD: Path to the python binary to be used
- NUMPY-PICKLE-LOCATION: PY4CL2 uses pickled files to transfer large arrays between lisp
and python efficiently. These can have sizes exceeding 100MB. It is recommended that this
be set to path on a ram-disk. See [this](https://unix.stackexchange.com/questions/66329/creating-a-ram-disk-on-linux) for instructions on creating a ram-disk on linux-based systems.
- NUMPY-PICKLE-LOWER-BOUND: The minimum size of the array for which PY4CL2 should use pickled files.
- PRINT-PYTHON-TRACEBACK: If non-NIL, the traceback on python’s side gets printed in
case of a python error. (NOTE: This is a new-feature, hence unstable)

Package

py4cl2.

Source

config.lisp.

Function: (setf config-var) (var)

Sets the value of VAR to NEW-VALUE in *CONFIG*. For all but PYCMD, the values are saved to a configuration-file for persistence whenever they are changed. To persist PYCMD, call SAVE-CONFIG.

Package

py4cl2.

Source

config.lisp.

Function: export-function (function python-name)

Makes a lisp FUNCTION available in python process as PYTHON-NAME

Package

py4cl2.

Source

import-export.lisp.

Function: initialize ()

Intended to be called first upon installation. Sets up default python command, and numpy pickle file and lower bounds.

Package

py4cl2.

Source

config.lisp.

Function: load-config ()

Load to *CONFIG* from /home/quickref/quicklisp/dists/quicklisp/software/py4cl2-v2.9.3/src/../.config

Package

py4cl2.

Source

config.lisp.

Function: py-cd (path)
Package

py4cl2.

Source

config.lisp.

Function: pycall (fun-name &rest args)

Calls FUN-NAME with ARGS as arguments. Arguments can be keyword based, or otherwise.

Package

py4cl2.

Source

callpython.lisp.

Function: pyeval (&rest args)

Calls python eval on args; PYTHONIZEs arg if it satisfies PYTHONIZEP. Eg.
> (let ((a 5)) (pyeval a "*" a))
25

Package

py4cl2.

Source

callpython.lisp.

Function: (setf pyeval) (&rest args)

Set an expression to a value. Just adds "=" and the value to the end of the expression. Note that the result is evaluated with exec rather than eval.
Example:
(setf (pyeval "a") 2) ; python "a=2"
Can be useful for modifying a value directly in python.

Package

py4cl2.

Source

callpython.lisp.

Function: pyexec (&rest args)

Calls python exec on args; PYTHONIZEs arg if it satisfies PYTHONIZEP.

Package

py4cl2.

Source

callpython.lisp.

Function: pygenerator (function stop-value)
Package

py4cl2.

Source

callpython.lisp.

Function: pyhelp (object)
Package

py4cl2.

Source

callpython.lisp.

Function: pyinterrupt (&optional process-info)

Issues a SIGINT command to the python process

Package

py4cl2.

Source

python-process.lisp.

Function: pymethod (object method &rest args)

PYCALLs METHOD of OBJECT with ARGS
Examples:
> (pymethod "’hello {0}’" ’format "world") "hello world"
> (pymethod ’(1 2 3) ’–len–)
3
Note: FUN-NAME is NOT PYTHONIZEd if it is a string.

Package

py4cl2.

Source

callpython.lisp.

Function: pymethod-list (python-object &key as-vector)
Package

py4cl2.

Source

import-export.lisp.

Function: pyslot-list (python-object &key as-vector)
Package

py4cl2.

Source

import-export.lisp.

Function: pyslot-value (object slot-name)
Package

py4cl2.

Source

callpython.lisp.

Function: (setf pyslot-value) (object slot-name)
Package

py4cl2.

Source

callpython.lisp.

Function: pystart (&optional command)

Start a new python subprocess
This sets the global variable *python* to the process handle,
in addition to returning it.
COMMAND is a string with the python executable to launch e.g. "python" By default this is is set to (CONFIG-VAR ’PYCMD)

Package

py4cl2.

Source

python-process.lisp.

Function: pystop (&optional process-info)

Stop (Quit) the python process PROCESS

Package

py4cl2.

Source

python-process.lisp.

Function: python-alive-p (&optional process-info)

Returns non-NIL if the python process is alive
(e.g. SBCL -> T, CCL -> RUNNING).
Optionally pass the process object returned by PYTHON-START

Package

py4cl2.

Source

python-process.lisp.

Reader: python-object-type (instance)
Writer: (setf python-object-type) (instance)
Package

py4cl2.

Source

reader.lisp.

Target Slot

type.

Function: python-start-if-not-alive ()

If no python process is running, tries to start it. If still not alive, raises a condition.

Package

py4cl2.

Source

python-process.lisp.

Function: pyversion-info ()

Return a list, using the result of python’s sys.version_info.

Package

py4cl2.

Source

callpython.lisp.

Function: raw-pyeval (&rest strings)

Calls python eval on the concatenation of strings, as they are, without any pythonization or modification.

Package

py4cl2.

Source

callpython.lisp.

Function: (setf raw-pyeval) (&rest args)
Package

py4cl2.

Source

callpython.lisp.

Function: raw-pyexec (&rest strings)

Calls python exec on the concatenation of strings, as they are, without any pythonization or modification.
NOTE: Like usual, there are peculiarities to exec commands.
For instance,
import sys
def foo:
sys.stdout.write(’hello’)
foo()
will result in ’sys’ name not defined PYERROR.

Package

py4cl2.

Source

callpython.lisp.

Function: save-config ()

Save to /home/quickref/quicklisp/dists/quicklisp/software/py4cl2-v2.9.3/src/../.config from *CONFIG*

Package

py4cl2.

Source

config.lisp.


5.1.4 Generic functions

Generic Function: python-getattr (object slot-name)

Called when python accesses an object’s slot (__getattr__)

Package

py4cl2.

Source

lisp-classes.lisp.

Generic Function: python-setattr (object slot-name value)

Called when python sets an object’s slot (__setattr__)

Package

py4cl2.

Source

lisp-classes.lisp.

Generic Function: pythonize (obj)

Convert an object into a string which can be written to stream. Default implementation creates a handle to an unknown Lisp object.

Package

py4cl2.

Source

writer.lisp.

Methods
Method: pythonize ((obj ratio))

Handle ratios, using Python’s Fraction if available

Method: pythonize ((obj python-object))

A handle for a python object, stored in a dict in Python

Method: pythonize ((obj function))

Handle a function by converting to a callback object
The lisp function is stored in the same object store as other objects.

Method: pythonize ((obj hash-table))

Convert hash-table to python map. Produces a string {key1:value1, key2:value2,}

Method: pythonize ((obj symbol))

Mapping from lisp symbol names to python names: symbol : symbol-name : python-name ’foo-bar : "FOO-BAR" : foo_bar ’|Foo-Bar| : "Foo-Bar" : Foo_Bar ’*foo-bar* : "*FOO-BAR*" : FOO_BAR
t : "T" : True
nil : "NIL" : False

Method: pythonize ((obj string))
Method: pythonize ((obj cons))

Convert a list. This leaves a trailing comma so that python evals a list with a single element as a tuple

Method: pythonize ((obj array))
Method: pythonize ((obj complex))

Create string of the form "(1+2j".
If imaginary part is negative the output is of form "(1+-2j" which is interpreted correctly by python (3.7.2).

Method: pythonize ((obj real))

Write a real number.
Note that python doesn’t handle ’d’,’f’, ’s’ or ’L’ exponent markers

Method: pythonize (obj)

5.1.5 Standalone methods

Method: print-object ((o python-object) s)
Source

reader.lisp.


5.1.6 Conditions

Condition: pyerror
Package

py4cl2.

Source

callpython.lisp.

Direct superclasses

error.

Direct methods

text.

Direct slots
Slot: text
Initargs

:text

Readers

text.

Writers

This slot is read-only.

Condition: python-eof-and-dead
Package

py4cl2.

Source

callpython.lisp.

Direct superclasses

end-of-file.

Direct methods

python-process.

Direct slots
Slot: python-process
Initargs

:python-process

Readers

python-process.

Writers

This slot is read-only.

Condition: python-eof-but-alive
Package

py4cl2.

Source

callpython.lisp.

Direct superclasses

end-of-file.

Direct methods

python-process.

Direct slots
Slot: python-process
Initargs

:python-process

Readers

python-process.

Writers

This slot is read-only.

Condition: python-process-startup-error
Package

py4cl2.

Source

python-process.lisp.

Direct superclasses

error.

Direct methods

command.

Direct slots
Slot: command
Initargs

:command

Readers

command.

Writers

This slot is read-only.


5.1.7 Structures

Structure: python-object

A handle for a python object
which couldn’t be translated into a Lisp value.
TYPE slot is the python type string
HANDLE slot is a unique key used to refer to a value in python.

Package

py4cl2.

Source

reader.lisp.

Direct superclasses

structure-object.

Direct methods
Direct slots
Slot: type
Package

common-lisp.

Type

string

Initform

""

Readers

python-object-type.

Writers

(setf python-object-type).

Slot: handle
Readers

python-object-handle.

Writers

(setf python-object-handle).


5.2 Internals


5.2.1 Constants

Constant: +py4cl2-config-path+
Package

py4cl2.

Source

config.lisp.


5.2.2 Special variables

Special Variable: *called-from-defpymodule*

Internal variable used for coordinating between DEFPYMODULE and DEFPYFUN.

Package

py4cl2.

Source

import-export.lisp.

Special Variable: *current-python-process-id*

A number which changes when python is started. This
is used to prevent garbage collection from deleting objects in the wrong python session

Package

py4cl2.

Source

python-process.lisp.

Special Variable: *defpymodule-cache*

If non-NIL, DEFPYMODULE produces the expansion during macroexpansion time. Use intended for DEFPYSUBMODULES.

Package

py4cl2.

Source

import-export.lisp.

Special Variable: *feature-exclusion-alist*
Package

py4cl2.

Source

features.lisp.

Special Variable: *freed-python-objects*

A list of handles to be freed. This is used because garbage collection may occur in parallel with the main thread.

Package

py4cl2.

Source

reader.lisp.

Special Variable: *function-reload-string*

String pyexec-ed at the start of a DEFPYFUN when SAFETY is T.

Package

py4cl2.

Source

import-export.lisp.

Special Variable: *handle-counter*
Package

py4cl2.

Source

writer.lisp.

Special Variable: *in-with-python-output*
Package

py4cl2.

Source

python-process.lisp.

Special Variable: *is-submodule*

Used for coordinating import statements from defpymodule while calling recursively

Package

py4cl2.

Source

import-export.lisp.

Special Variable: *lisp-objects*
Package

py4cl2.

Source

writer.lisp.

Special Variable: *lisp-package-supplied-p*

Internal variable used by PYMODULE-IMPORT-STRING to determine the import string.

Package

py4cl2.

Source

import-export.lisp.

Special Variable: *lisp-to-python-alist*
Package

py4cl2.

Source

writer.lisp.

Special Variable: *numpy-pickle-index*

Used for transferring multiple numpy-pickled arrays in one pyeval/exec/etc

Package

py4cl2.

Source

writer.lisp.

Special Variable: *py4cl-tests*
Package

py4cl2.

Source

python-process.lisp.

Special Variable: *python*

Most recently started python subprocess

Package

py4cl2.

Source

python-process.lisp.

Special Variable: *python-code*
Package

py4cl2.

Source

python-process.lisp.

Special Variable: *python-lock*
Package

py4cl2.

Source

callpython.lisp.

Special Variable: *python-output-semaphore*
Package

py4cl2.

Source

python-process.lisp.

Special Variable: *python-output-thread*
Package

py4cl2.

Source

python-process.lisp.

Special Variable: *python-process-busy-p*

Used by pyinterrupt to determine if python process is waiting for input, or
is busy processing.

A possible workaround is to use strace.
See https://askubuntu.com/questions/1118109/how-do-i-tell-if-a-command-is-running-or-waiting-for-user-input

Package

py4cl2.

Source

python-process.lisp.

Special Variable: *python-startup-error*
Package

py4cl2.

Source

python-process.lisp.


5.2.3 Macros

Macro: defvar-doc (name doc)
Package

py4cl2.

Source

import-export.lisp.


5.2.4 Ordinary functions

Function: %chain* (&rest chain)
Package

py4cl2.

Source

callpython.lisp.

Function: %pycall-args (&rest args)
Package

py4cl2.

Source

callpython.lisp.

Function: %pythonize (object)

A wrapper around PYTHONIZE to take custom *PYTHONIZERS* into account.

Package

py4cl2.

Source

config.lisp.

Function: break-into-words (char-list)

Returns ((h e l l o) (W o r l d)), given (h e l l o W o r l d).

Package

py4cl2.

Source

arg-list.lisp.

Function: builtin-p (pymodule-name)

Some builtin functions like ’sum’ do not take keyword args.

Package

py4cl2.

Source

import-export.lisp.

Function: clear-lisp-objects ()

Clear the *lisp-objects* object store, allowing them to be GC’d

Package

py4cl2.

Source

writer.lisp.

Function: collect-first-word (char-list)

Returns ((h e l l o) W o r l d), given (h e l l o W o r l d).

Package

py4cl2.

Source

arg-list.lisp.

Function: copy-python-object (instance)
Package

py4cl2.

Source

reader.lisp.

Function: customize (object)
Package

py4cl2.

Source

config.lisp.

Function: defpyfun* (fun-name pymodule-name as lisp-fun-name lisp-package safety)
Package

py4cl2.

Source

import-export.lisp.

Function: defpymodule* (pymodule-name import-submodules lisp-package lisp-package-supplied-p reload safety continue-ignoring-errors silent)

Returns multiple values:
- a DEFVAR form to capture the existence of package before ensuring it - an ENSURE-PACKAGE form
- the actual form that defines the package and functions

Package

py4cl2.

Source

import-export.lisp.

Function: defpysubmodules (pymodule-name lisp-package continue-ignoring-errors)
Package

py4cl2.

Source

import-export.lisp.

Function: delete-freed-python-objects ()
Package

py4cl2.

Source

reader.lisp.

Function: delete-numpy-pickle-arrays ()

Delete pickled arrays, to free space.

Package

py4cl2.

Source

reader.lisp.

Function: dispatch-messages (process)

Read response from python, loop to handle any callbacks

Package

py4cl2.

Source

callpython.lisp.

Function: dispatch-reply (stream value)
Package

py4cl2.

Source

callpython.lisp.

Function: ensure-package (package-name &rest args)
Package

py4cl2.

Source

import-export.lisp.

Function: free-handle (handle)

Remove an object with HANDLE from the hash table

Package

py4cl2.

Source

writer.lisp.

Function: free-python-object (python-id handle)
Package

py4cl2.

Source

reader.lisp.

Function: fun-symbol (pyfun-name pyfullname lisp-package &optional ensure-unique)
Package

py4cl2.

Source

import-export.lisp.

Function: function-reload-string (&key pymodule-name lisp-package fun-name as)
Package

py4cl2.

Source

import-export.lisp.

Function: get-arg-list (fullname lisp-package)

Returns a list of two lists: PARAMETER-LIST and PASS_LIST

Package

py4cl2.

Source

arg-list.lisp.

Function: get-unique-symbol (symbol-name package-name)
Package

py4cl2.

Source

arg-list.lisp.

Function: lisp-object (handle)

Get the lisp object corresponding to HANDLE

Package

py4cl2.

Source

writer.lisp.

Function: lispify-name (name)

Converts NAME to a lisp-like name. Specifically: 1. Replaces underscores with hyphens.
2. CamelCase is converted to CAMEL-CASE

Package

py4cl2.

Source

arg-list.lisp.

Function: make-python-object (&key type handle)
Package

py4cl2.

Source

reader.lisp.

Function: make-python-object-finalize (&key type handle)

Make a PYTHON-OBJECT struct with a finalizer.
This deletes the object from the dict store in python.

Uses trivial-garbage (public domain)

Package

py4cl2.

Source

reader.lisp.

Function: numeric-char-p (ch)
Package

py4cl2.

Source

arg-list.lisp.

Function: numpy-installed-p ()
Package

py4cl2.

Source

features.lisp.

Function: object-handle (object)

Store OBJECT and return a handle

Package

py4cl2.

Source

writer.lisp.

Function: pymodule-import-string (pymodule-name lisp-package)
Package

py4cl2.

Source

import-export.lisp.

Reader: python-object-handle (instance)
Writer: (setf python-object-handle) (instance)
Package

py4cl2.

Source

reader.lisp.

Target Slot

handle.

Function: python-object-p (object)
Package

py4cl2.

Source

reader.lisp.

Function: pythonize-kwargs (arg-plist)
Package

py4cl2.

Source

arg-list.lisp.

Function: raw-py (cmd-char &rest strings)

Intended as an abstraction to RAW-PYEVAL and RAW_PYEXEC. Passes strings as they are, without any ’pythonize’ation.

Package

py4cl2.

Source

callpython.lisp.

Function: split-point-p (pch ch)
Package

py4cl2.

Source

arg-list.lisp.

Function: stream-read-string (stream)

Reads a string from a stream
Expects a line containing the number of chars following e.g. ’5~%hello’
Returns the string or nil on error

Package

py4cl2.

Source

reader.lisp.

Function: stream-read-value (stream)

Get a value from a stream
Currently works by reading a string then using read-from-string

Package

py4cl2.

Source

reader.lisp.

Function: stream-write-string (str stream)

Write a string to a stream, putting the length first

Package

py4cl2.

Source

writer.lisp.

Function: stream-write-value (value stream)

Write a value to a stream, in a format which can be read by the python subprocess as the corresponding python type

Package

py4cl2.

Source

writer.lisp.

Function: take-input (prompt default)
Package

py4cl2.

Source

config.lisp.


5.2.5 Generic functions

Generic Function: %get-arg-list (package fullname lisp-package)
Package

py4cl2.

Methods
Method: %get-arg-list (package fullname lisp-package)
Source

arg-list.lisp.

Method: %get-arg-list ((package (eql :|type|)) fullname lisp-package)
Source

arg-list.lisp.

Method: %get-arg-list ((package (eql :|builtin_function_or_method|)) fullname lisp-package)
Source

arg-list.lisp.

Method: %get-arg-list ((package (eql :|numpy.ufunc|)) fullname lisp-package)
Source

arg-list.lisp.

Generic Reader: command (condition)
Package

py4cl2.

Methods
Reader Method: command ((condition python-process-startup-error))
Source

python-process.lisp.

Target Slot

command.

Generic Reader: python-process (condition)
Package

py4cl2.

Methods
Reader Method: python-process ((condition python-eof-and-dead))
Source

callpython.lisp.

Target Slot

python-process.

Reader Method: python-process ((condition python-eof-but-alive))
Source

callpython.lisp.

Target Slot

python-process.

Generic Reader: text (condition)
Package

py4cl2.

Methods
Reader Method: text ((condition pyerror))
Source

callpython.lisp.

Target Slot

text.


5.2.6 Conditions

Condition: both-positional-and-keyword-rest
Package

py4cl2.

Source

arg-list.lisp.

Direct superclasses

default-arg-list-necessary.

Condition: default-arg-list-necessary
Package

py4cl2.

Source

arg-list.lisp.

Direct superclasses

condition.

Direct subclasses
Condition: default-is-python-object
Package

py4cl2.

Source

arg-list.lisp.

Direct superclasses

default-arg-list-necessary.

Condition: no-lispifier-found
Package

py4cl2.

Source

config.lisp.

Direct superclasses

condition.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   %   (  
B   C   D   E   F   G   I   L   M   N   O   P   R   S   T   W  
Index Entry  Section

%
%chain*: Private ordinary functions
%get-arg-list: Private generic functions
%get-arg-list: Private generic functions
%get-arg-list: Private generic functions
%get-arg-list: Private generic functions
%get-arg-list: Private generic functions
%pycall-args: Private ordinary functions
%pythonize: Private ordinary functions

(
(setf chain*): Public ordinary functions
(setf config-var): Public ordinary functions
(setf pyeval): Public ordinary functions
(setf pyslot-value): Public ordinary functions
(setf python-object-handle): Private ordinary functions
(setf python-object-type): Public ordinary functions
(setf raw-pyeval): Public ordinary functions

B
break-into-words: Private ordinary functions
builtin-p: Private ordinary functions

C
chain: Public macros
chain*: Public ordinary functions
clear-lisp-objects: Private ordinary functions
collect-first-word: Private ordinary functions
command: Private generic functions
command: Private generic functions
config-var: Public ordinary functions
copy-python-object: Private ordinary functions
customize: Private ordinary functions

D
defpyfun: Public macros
defpyfun*: Private ordinary functions
defpyfuns: Public macros
defpymodule: Public macros
defpymodule*: Private ordinary functions
defpysubmodules: Private ordinary functions
defvar-doc: Private macros
delete-freed-python-objects: Private ordinary functions
delete-numpy-pickle-arrays: Private ordinary functions
dispatch-messages: Private ordinary functions
dispatch-reply: Private ordinary functions

E
ensure-package: Private ordinary functions
export-function: Public ordinary functions

F
free-handle: Private ordinary functions
free-python-object: Private ordinary functions
fun-symbol: Private ordinary functions
Function, %chain*: Private ordinary functions
Function, %pycall-args: Private ordinary functions
Function, %pythonize: Private ordinary functions
Function, (setf chain*): Public ordinary functions
Function, (setf config-var): Public ordinary functions
Function, (setf pyeval): Public ordinary functions
Function, (setf pyslot-value): Public ordinary functions
Function, (setf python-object-handle): Private ordinary functions
Function, (setf python-object-type): Public ordinary functions
Function, (setf raw-pyeval): Public ordinary functions
Function, break-into-words: Private ordinary functions
Function, builtin-p: Private ordinary functions
Function, chain*: Public ordinary functions
Function, clear-lisp-objects: Private ordinary functions
Function, collect-first-word: Private ordinary functions
Function, config-var: Public ordinary functions
Function, copy-python-object: Private ordinary functions
Function, customize: Private ordinary functions
Function, defpyfun*: Private ordinary functions
Function, defpymodule*: Private ordinary functions
Function, defpysubmodules: Private ordinary functions
Function, delete-freed-python-objects: Private ordinary functions
Function, delete-numpy-pickle-arrays: Private ordinary functions
Function, dispatch-messages: Private ordinary functions
Function, dispatch-reply: Private ordinary functions
Function, ensure-package: Private ordinary functions
Function, export-function: Public ordinary functions
Function, free-handle: Private ordinary functions
Function, free-python-object: Private ordinary functions
Function, fun-symbol: Private ordinary functions
Function, function-reload-string: Private ordinary functions
Function, get-arg-list: Private ordinary functions
Function, get-unique-symbol: Private ordinary functions
Function, initialize: Public ordinary functions
Function, lisp-object: Private ordinary functions
Function, lispify-name: Private ordinary functions
Function, load-config: Public ordinary functions
Function, make-python-object: Private ordinary functions
Function, make-python-object-finalize: Private ordinary functions
Function, numeric-char-p: Private ordinary functions
Function, numpy-installed-p: Private ordinary functions
Function, object-handle: Private ordinary functions
Function, py-cd: Public ordinary functions
Function, pycall: Public ordinary functions
Function, pyeval: Public ordinary functions
Function, pyexec: Public ordinary functions
Function, pygenerator: Public ordinary functions
Function, pyhelp: Public ordinary functions
Function, pyinterrupt: Public ordinary functions
Function, pymethod: Public ordinary functions
Function, pymethod-list: Public ordinary functions
Function, pymodule-import-string: Private ordinary functions
Function, pyslot-list: Public ordinary functions
Function, pyslot-value: Public ordinary functions
Function, pystart: Public ordinary functions
Function, pystop: Public ordinary functions
Function, python-alive-p: Public ordinary functions
Function, python-object-handle: Private ordinary functions
Function, python-object-p: Private ordinary functions
Function, python-object-type: Public ordinary functions
Function, python-start-if-not-alive: Public ordinary functions
Function, pythonize-kwargs: Private ordinary functions
Function, pyversion-info: Public ordinary functions
Function, raw-py: Private ordinary functions
Function, raw-pyeval: Public ordinary functions
Function, raw-pyexec: Public ordinary functions
Function, save-config: Public ordinary functions
Function, split-point-p: Private ordinary functions
Function, stream-read-string: Private ordinary functions
Function, stream-read-value: Private ordinary functions
Function, stream-write-string: Private ordinary functions
Function, stream-write-value: Private ordinary functions
Function, take-input: Private ordinary functions
function-reload-string: Private ordinary functions

G
Generic Function, %get-arg-list: Private generic functions
Generic Function, command: Private generic functions
Generic Function, python-getattr: Public generic functions
Generic Function, python-process: Private generic functions
Generic Function, python-setattr: Public generic functions
Generic Function, pythonize: Public generic functions
Generic Function, text: Private generic functions
get-arg-list: Private ordinary functions
get-unique-symbol: Private ordinary functions

I
initialize: Public ordinary functions

L
lisp-object: Private ordinary functions
lispify-name: Private ordinary functions
load-config: Public ordinary functions

M
Macro, chain: Public macros
Macro, defpyfun: Public macros
Macro, defpyfuns: Public macros
Macro, defpymodule: Public macros
Macro, defvar-doc: Private macros
Macro, with-lispifiers: Public macros
Macro, with-python-output: Public macros
Macro, with-pythonizers: Public macros
Macro, with-remote-objects: Public macros
Macro, with-remote-objects*: Public macros
make-python-object: Private ordinary functions
make-python-object-finalize: Private ordinary functions
Method, %get-arg-list: Private generic functions
Method, %get-arg-list: Private generic functions
Method, %get-arg-list: Private generic functions
Method, %get-arg-list: Private generic functions
Method, command: Private generic functions
Method, print-object: Public standalone methods
Method, python-process: Private generic functions
Method, python-process: Private generic functions
Method, pythonize: Public generic functions
Method, pythonize: Public generic functions
Method, pythonize: Public generic functions
Method, pythonize: Public generic functions
Method, pythonize: Public generic functions
Method, pythonize: Public generic functions
Method, pythonize: Public generic functions
Method, pythonize: Public generic functions
Method, pythonize: Public generic functions
Method, pythonize: Public generic functions
Method, pythonize: Public generic functions
Method, text: Private generic functions

N
numeric-char-p: Private ordinary functions
numpy-installed-p: Private ordinary functions

O
object-handle: Private ordinary functions

P
print-object: Public standalone methods
py-cd: Public ordinary functions
pycall: Public ordinary functions
pyeval: Public ordinary functions
pyexec: Public ordinary functions
pygenerator: Public ordinary functions
pyhelp: Public ordinary functions
pyinterrupt: Public ordinary functions
pymethod: Public ordinary functions
pymethod-list: Public ordinary functions
pymodule-import-string: Private ordinary functions
pyslot-list: Public ordinary functions
pyslot-value: Public ordinary functions
pystart: Public ordinary functions
pystop: Public ordinary functions
python-alive-p: Public ordinary functions
python-getattr: Public generic functions
python-object-handle: Private ordinary functions
python-object-p: Private ordinary functions
python-object-type: Public ordinary functions
python-process: Private generic functions
python-process: Private generic functions
python-process: Private generic functions
python-setattr: Public generic functions
python-start-if-not-alive: Public ordinary functions
pythonize: Public generic functions
pythonize: Public generic functions
pythonize: Public generic functions
pythonize: Public generic functions
pythonize: Public generic functions
pythonize: Public generic functions
pythonize: Public generic functions
pythonize: Public generic functions
pythonize: Public generic functions
pythonize: Public generic functions
pythonize: Public generic functions
pythonize: Public generic functions
pythonize-kwargs: Private ordinary functions
pyversion-info: Public ordinary functions

R
raw-py: Private ordinary functions
raw-pyeval: Public ordinary functions
raw-pyexec: Public ordinary functions

S
save-config: Public ordinary functions
split-point-p: Private ordinary functions
stream-read-string: Private ordinary functions
stream-read-value: Private ordinary functions
stream-write-string: Private ordinary functions
stream-write-value: Private ordinary functions

T
take-input: Private ordinary functions
text: Private generic functions
text: Private generic functions

W
with-lispifiers: Public macros
with-python-output: Public macros
with-pythonizers: Public macros
with-remote-objects: Public macros
with-remote-objects*: Public macros


A.3 Variables

Jump to:   *   +  
C   H   P   S   T  
Index Entry  Section

*
*additional-init-codes*: Public special variables
*called-from-defpymodule*: Private special variables
*config*: Public special variables
*current-python-process-id*: Private special variables
*defpymodule-cache*: Private special variables
*defpymodule-silent-p*: Public special variables
*feature-exclusion-alist*: Private special variables
*freed-python-objects*: Private special variables
*function-reload-string*: Private special variables
*handle-counter*: Private special variables
*in-with-python-output*: Private special variables
*internal-features*: Public special variables
*is-submodule*: Private special variables
*lisp-objects*: Private special variables
*lisp-package-supplied-p*: Private special variables
*lisp-to-python-alist*: Private special variables
*lispifiers*: Public special variables
*numpy-pickle-index*: Private special variables
*print-python-object*: Public special variables
*py4cl-tests*: Private special variables
*python*: Private special variables
*python-code*: Private special variables
*python-lock*: Private special variables
*python-output-semaphore*: Private special variables
*python-output-thread*: Private special variables
*python-process-busy-p*: Private special variables
*python-startup-error*: Private special variables
*pythonizers*: Public special variables
*warn-on-unavailable-feature-usage*: Public special variables

+
+py4cl2-config-path+: Private constants

C
command: Public conditions
Constant, +py4cl2-config-path+: Private constants

H
handle: Public structures

P
python-process: Public conditions
python-process: Public conditions

S
Slot, command: Public conditions
Slot, handle: Public structures
Slot, python-process: Public conditions
Slot, python-process: Public conditions
Slot, text: Public conditions
Slot, type: Public structures
Special Variable, *additional-init-codes*: Public special variables
Special Variable, *called-from-defpymodule*: Private special variables
Special Variable, *config*: Public special variables
Special Variable, *current-python-process-id*: Private special variables
Special Variable, *defpymodule-cache*: Private special variables
Special Variable, *defpymodule-silent-p*: Public special variables
Special Variable, *feature-exclusion-alist*: Private special variables
Special Variable, *freed-python-objects*: Private special variables
Special Variable, *function-reload-string*: Private special variables
Special Variable, *handle-counter*: Private special variables
Special Variable, *in-with-python-output*: Private special variables
Special Variable, *internal-features*: Public special variables
Special Variable, *is-submodule*: Private special variables
Special Variable, *lisp-objects*: Private special variables
Special Variable, *lisp-package-supplied-p*: Private special variables
Special Variable, *lisp-to-python-alist*: Private special variables
Special Variable, *lispifiers*: Public special variables
Special Variable, *numpy-pickle-index*: Private special variables
Special Variable, *print-python-object*: Public special variables
Special Variable, *py4cl-tests*: Private special variables
Special Variable, *python*: Private special variables
Special Variable, *python-code*: Private special variables
Special Variable, *python-lock*: Private special variables
Special Variable, *python-output-semaphore*: Private special variables
Special Variable, *python-output-thread*: Private special variables
Special Variable, *python-process-busy-p*: Private special variables
Special Variable, *python-startup-error*: Private special variables
Special Variable, *pythonizers*: Public special variables
Special Variable, *warn-on-unavailable-feature-usage*: Public special variables

T
text: Public conditions
type: Public structures


A.4 Data types

Jump to:   .  
A   B   C   D   F   I   L   N   P   R   S   W  
Index Entry  Section

.
.config: The py4cl2/․config file

A
arg-list.lisp: The py4cl2/arg-list․lisp file

B
both-positional-and-keyword-rest: Private conditions

C
callpython.lisp: The py4cl2/callpython․lisp file
Condition, both-positional-and-keyword-rest: Private conditions
Condition, default-arg-list-necessary: Private conditions
Condition, default-is-python-object: Private conditions
Condition, no-lispifier-found: Private conditions
Condition, pyerror: Public conditions
Condition, python-eof-and-dead: Public conditions
Condition, python-eof-but-alive: Public conditions
Condition, python-process-startup-error: Public conditions
config.lisp: The py4cl2/config․lisp file

D
default-arg-list-necessary: Private conditions
default-is-python-object: Private conditions
do-after-load.lisp: The py4cl2/do-after-load․lisp file

F
features.lisp: The py4cl2/features․lisp file
File, .config: The py4cl2/․config file
File, arg-list.lisp: The py4cl2/arg-list․lisp file
File, callpython.lisp: The py4cl2/callpython․lisp file
File, config.lisp: The py4cl2/config․lisp file
File, do-after-load.lisp: The py4cl2/do-after-load․lisp file
File, features.lisp: The py4cl2/features․lisp file
File, import-export.lisp: The py4cl2/import-export․lisp file
File, lisp-classes.lisp: The py4cl2/lisp-classes․lisp file
File, package.lisp: The py4cl2/package․lisp file
File, py4cl2.asd: The py4cl2/py4cl2․asd file
File, python-code: The py4cl2/python-code file
File, python-process.lisp: The py4cl2/python-process․lisp file
File, reader.lisp: The py4cl2/reader․lisp file
File, writer.lisp: The py4cl2/writer․lisp file

I
import-export.lisp: The py4cl2/import-export․lisp file

L
lisp-classes.lisp: The py4cl2/lisp-classes․lisp file

N
no-lispifier-found: Private conditions

P
Package, py4cl2: The py4cl2 package
package.lisp: The py4cl2/package․lisp file
py4cl2: The py4cl2 system
py4cl2: The py4cl2 package
py4cl2.asd: The py4cl2/py4cl2․asd file
pyerror: Public conditions
python-code: The py4cl2/python-code file
python-eof-and-dead: Public conditions
python-eof-but-alive: Public conditions
python-object: Public structures
python-process-startup-error: Public conditions
python-process.lisp: The py4cl2/python-process․lisp file

R
reader.lisp: The py4cl2/reader․lisp file

S
Structure, python-object: Public structures
System, py4cl2: The py4cl2 system

W
writer.lisp: The py4cl2/writer․lisp file