Skip to content

Commit a7223f8

Browse files
committed
[doc][misc] pythonize, rename parameter of pyvalue, indentation
1 parent deba1d6 commit a7223f8

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

src/python-process.lisp

+10-10
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,9 @@ Use PYVALUE* if you want to refer to names containing full-stops."
501501
(string slot-name)
502502
(symbol (pythonize-symbol slot-name))))
503503
(return-value (pyforeign-funcall "PyObject_GetAttrString"
504-
:pointer object-pointer
505-
:string slot-name
506-
:pointer)))
504+
:pointer object-pointer
505+
:string slot-name
506+
:pointer)))
507507
(ensure-non-null-pointer return-value
508508
:format-control
509509
"~A~%in python does not have the attribute ~A"
@@ -561,7 +561,7 @@ Use PYVALUE* if you want to refer to names containing full-stops."
561561
(when previous-value
562562
(setf (%pyslot-value previous-value previous-name) new-value)))))
563563

564-
(defun pyvalue (python-value-or-variable)
564+
(defun pyvalue (python-name-or-variable)
565565
"Get the value of a python-name-or-variable.
566566
Example:
567567
@@ -573,13 +573,13 @@ Example:
573573
\"/home/user/miniconda3/lib/python3.10/lib-dynload\"
574574
\"/home/user/miniconda3/lib/python3.10/site-packages\")
575575
"
576-
(declare (type (or python-object string) python-value-or-variable))
576+
(declare (type (or python-object string) python-name-or-variable))
577577
(python-start-if-not-alive)
578578
(if *in-with-remote-objects-p*
579-
(pyvalue* python-value-or-variable)
580-
(with-pygc (lispify (pyvalue* python-value-or-variable)))))
579+
(pyvalue* python-name-or-variable)
580+
(with-pygc (lispify (pyvalue* python-name-or-variable)))))
581581

582-
(defun (setf pyvalue) (new-value python-value-or-variable)
582+
(defun (setf pyvalue) (new-value python-name-or-variable)
583583
"Set the value of a python-name-or-variable.
584584
Example:
585585
@@ -596,10 +596,10 @@ Example:
596596
\"/home/user/miniconda3/lib/python3.10/lib-dynload\"
597597
\"/home/user/miniconda3/lib/python3.10/site-packages\")
598598
"
599-
(declare (type string python-value-or-variable))
599+
(declare (type string python-name-or-variable))
600600
(python-start-if-not-alive)
601601
(with-pygc
602-
(setf (pyvalue* python-value-or-variable)
602+
(setf (pyvalue* python-name-or-variable)
603603
;; UNTRACK because we do not want to lose reference to this object!
604604
(pyuntrack (%pythonize new-value)))
605605
new-value))

src/pythonizers.lisp

+10-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,16 @@ the same lisp objects which are EQ to each other. Returns NIL in all other cases
100100
`(pyeval ,(pycall "repr" pointer))))))
101101

102102
(declaim (type (function (t) foreign-pointer) pythonize))
103-
(defgeneric pythonize (lisp-value-or-object))
103+
(defgeneric pythonize (lisp-value-or-object)
104+
(:documentation "Given a lisp object, return a CFFI:FOREIGN-POINTER pointing to the python object corresponding to the given lisp object.
105+
106+
The implemented methods are expected to return a new (strong) reference
107+
to the python object. The method is also expected to call PYTRACK
108+
to notify the PYGC functionality to delete the reference once the object
109+
is no longer needed.
110+
111+
See the documentation for PYGC to understand when reference deletion
112+
takes place."))
104113

105114
(defmethod pythonize (lisp-object)
106115
(pycall* "_py4cl_UnknownLispObject" (object-handle lisp-object)))

0 commit comments

Comments
 (0)