Import upstream version 1.1.0+git20210519.1.fa4db98
Debian Janitor
2 years ago
5 | 5 |
Author: The Nucleic Development Team
|
6 | 6 |
Author-email: sccolbert@gmail.com
|
7 | 7 |
License: UNKNOWN
|
8 | |
Description: cppy
|
|
8 |
Description: Cppy
|
9 | 9 |
====
|
10 | 10 |
|
11 | 11 |
.. image:: https://travis-ci.org/nucleic/cppy.svg?branch=master
|
0 | |
cppy
|
|
0 |
Cppy
|
1 | 1 |
====
|
2 | 2 |
|
3 | 3 |
.. image:: https://travis-ci.org/nucleic/cppy.svg?branch=master
|
5 | 5 |
Author: The Nucleic Development Team
|
6 | 6 |
Author-email: sccolbert@gmail.com
|
7 | 7 |
License: UNKNOWN
|
8 | |
Description: cppy
|
|
8 |
Description: Cppy
|
9 | 9 |
====
|
10 | 10 |
|
11 | 11 |
.. image:: https://travis-ci.org/nucleic/cppy.svg?branch=master
|
0 | 0 |
Error reporting
|
1 | 1 |
===============
|
2 | 2 |
|
3 | |
In addition to `cppy::ptr`, cppy provides a set a convenience function for
|
|
3 |
In addition to `cppy::ptr`, cppy provides a set of convenience functions for
|
4 | 4 |
reporting errors which all return a NULL pointer allowing them to be used as
|
5 | 5 |
follows:
|
6 | 6 |
|
|
17 | 17 |
Functions
|
18 | 18 |
---------
|
19 | 19 |
|
20 | |
Functions taking two arguments provide sensible pre-formated error messages.
|
|
20 |
Functions taking two arguments provide sensible pre-formatted error messages.
|
21 | 21 |
|
22 | 22 |
.. code:: c++
|
23 | 23 |
|
2 | 2 |
You can adapt this file completely to your liking, but it should at least
|
3 | 3 |
contain the root `toctree` directive.
|
4 | 4 |
|
5 | |
Welcome to cppy's documentation!
|
|
5 |
Welcome to Cppy's documentation!
|
6 | 6 |
================================
|
7 | 7 |
|
8 | |
Cpppy is a small C++ header library which makes it easier to write Python
|
|
8 |
Cppy is a small C++ header library which makes it easier to write Python
|
9 | 9 |
extension modules. The primary feature is a PyObject smart pointer which
|
10 | 10 |
automatically handles reference counting and provides convenience methods for
|
11 | 11 |
performing common object operations.
|
0 | 0 |
Installation and use with setuptools
|
1 | 1 |
====================================
|
2 | 2 |
|
3 | |
Since cppy is nothing else than a collection of header that are only compiled
|
|
3 |
Since Cppy is nothing else than a collection of header that are only compiled
|
4 | 4 |
when used, installing it is extremely straightforward using pip::
|
5 | 5 |
|
6 | 6 |
$ pip install cppy
|
7 | 7 |
|
8 | 8 |
If you want to run the development version, you can install directly from
|
9 | |
Github::
|
|
9 |
GitHub::
|
10 | 10 |
|
11 | 11 |
$ pip install https://github.com/nucleic/cppy
|
12 | 12 |
|
13 | 13 |
|
14 | |
Using cppy in an extensions
|
|
14 |
Using Cppy in an extensions
|
15 | 15 |
---------------------------
|
16 | 16 |
|
17 | |
To use cppy in your extension (written in C++), you simply need to include it.
|
|
17 |
To use Cppy in your extension (written in C++), you simply need to include it.
|
18 | 18 |
|
19 | 19 |
.. code:: c++
|
20 | 20 |
|
|
23 | 23 |
Cppy includes Python.h so when including cppy.h you do not need to also include
|
24 | 24 |
Python.h.
|
25 | 25 |
|
26 | |
Every functions, classes exposed by cppy are stored in the `cppy` namespace.
|
|
26 |
Every functions, classes exposed by Cppy are stored in the `cppy` namespace.
|
27 | 27 |
|
28 | 28 |
.. code:: c++
|
29 | 29 |
|
|
34 | 34 |
-------------------
|
35 | 35 |
|
36 | 36 |
Cppy is only needed during the installation step of the projects using it. The
|
37 | |
following example setup.py script illustrates how to use cppy without requiring
|
|
37 |
following example setup.py script illustrates how to use Cppy without requiring
|
38 | 38 |
it to be installed before `setup.py` is run.
|
39 | 39 |
|
40 | 40 |
.. code:: python
|
27 | 27 |
In this situation you own a reference.
|
28 | 28 |
|
29 | 29 |
- Borrowed reference:
|
30 | |
Some functions (`PyList_GetItem`, `PyTuple_GetItem`) do not incref the object
|
31 | |
count before returning. In that case, you have only a borrowed reference, you
|
32 | |
are not responsible for decrefing the object reference count.
|
|
30 |
Some functions (`PyList_GetItem`, `PyTuple_GetItem`, `PyDict_GetItem`, ...)
|
|
31 |
do not incref the object count before returning. In that case, you have only
|
|
32 |
a borrowed reference, you are not responsible for decrefing the object
|
|
33 |
reference count.
|
33 | 34 |
|
34 | 35 |
Borrowed references allow to avoid the cost of increfing/decrefing which is
|
35 | 36 |
nice. However since you do not own the reference, if the object referenced is
|