Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
Signed-off-by: Jade Abraham <[email protected]>
  • Loading branch information
jabraham17 committed Feb 12, 2025
1 parent cd6ce7f commit dc57d7a
Showing 1 changed file with 20 additions and 28 deletions.
48 changes: 20 additions & 28 deletions modules/packages/Python.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
.. warning::
Chapel programs compiled in this wys are compiled for a specific Python
Chapel programs compiled in this way are compiled for a specific Python
version. Attempting to run the compiled program with a different Python
version may have unexpected results.
Expand Down Expand Up @@ -560,7 +560,9 @@ module Python {
Import a Python module. This is equivalent to calling ``import modName``
in Python.
See :proc:`Module.init` for more information.
.. warning::
Importing a second module with the same name will overwrite the first.
:arg modName: The name of the module that will be created. Note that if
the module name already exists, it will be replaced.
Expand All @@ -569,15 +571,20 @@ module Python {
return new Module(this, modName);
}
/*
Import a Python module, using the provided ``moduleContents``.
Import a Python module, using the provided ``moduleContents``. This is
equivalent to putting the code in a file, and then importing the file
via the file/module name.
See :proc:`Module.init` for more information.
.. warning::
Importing a second module with the same name will overwrite the first.
:arg modName: The name of the module that will be created. Note that if
the module name already exists, it will be replaced.
:arg moduleContents: The contents of the module. This can be a string of
Python code or a bytes object containing Python
bytecode (e.g. from a ``*.pyc`` file).
:arg moduleContents: The contents of the module. This can be a
:type:`string` of Python code or a :type:`bytes`
object containing Python bytecode
(i.e. from a ``*.pyc`` file).
*/
proc importModule(modName: string, moduleContents): owned Module throws
where moduleContents.type == string || moduleContents.type == bytes {
Expand All @@ -588,9 +595,7 @@ module Python {
Load a `Python Pickle <https://docs.python.org/3/library/pickle.html>`_
as a Python object.
See :proc:`Value.init` for more information.
:arg pickle: The pickle to load
:arg pickle: The pickle data to load
*/
proc load(pickle: bytes): owned Value throws {
return new Value(this, pickle);
Expand Down Expand Up @@ -1313,6 +1318,7 @@ module Python {

/*
Creates a new Python object from a pickle.
See :proc:`Interpreter.loadPickle`.
:arg interpreter: The interpreter that this object is associated with.
:arg pickleData: The pickle data to load.
Expand Down Expand Up @@ -1637,7 +1643,7 @@ module Python {
}

/*
Stop owning ``val``, return's the underlying ``c_ptr(PyObject)``.
Stop owning ``val``, returns the underlying ``c_ptr(PyObject)``.
The caller is responsible for decrementing the reference count of the
returned object.
Expand Down Expand Up @@ -1691,7 +1697,7 @@ module Python {
var modName: string;

/*
Import a Python module by name.
Import a Python module by name. See :proc:`Interpreter.importModule`.
*/
proc init(interpreter: borrowed Interpreter, in modName: string) {
super.init(interpreter,
Expand All @@ -1701,14 +1707,7 @@ module Python {

/*
Import a Python module from a string using an arbitrary name.
This is equivalent to running the code in a file, and then importing the
module.
.. warning::
Importing a second module with the same name will overwrite the first.
See :proc:`Interpreter.importModule`.
*/
proc init(interpreter: borrowed Interpreter,
in modName: string, in moduleContents: string) throws {
Expand All @@ -1720,14 +1719,7 @@ module Python {

/*
Import a Python module from bytecode using an arbitrary name.
This is equivalent to running the code in a file, and then importing the
module. However, this takes the bytecode directly (i.e. ``*.pyc`` files),
rather than the source.
.. warning::
Importing a second module with the same name will overwrite the first.
See :proc:`Interpreter.importModule`.
*/
proc init(interpreter: borrowed Interpreter,
in modName: string, in moduleBytecode: bytes) throws {
Expand Down

0 comments on commit dc57d7a

Please sign in to comment.