Skip to content

Commit 2e19b16

Browse files
committed
Changes after David's Review
1 parent 927d649 commit 2e19b16

File tree

1 file changed

+96
-59
lines changed

1 file changed

+96
-59
lines changed

docs/UsingCppInterOp.rst

Lines changed: 96 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -65,40 +65,44 @@ robust (simple function calls, no inheritance, etc.). The goal is to make it as
6565
close to the compiler API as possible, and each routine should do just one thing.
6666
that it was designed for.
6767

68-
Further Enhancing the Dynamic/Automatic bindings in CPPYY
69-
=========================================================
68+
How cppyy relates to CppInterOp and how it works
69+
================================================
7070

71-
CppInterOp ties into the following major enhancements in cppyy:
71+
CppInterOp ties into several `enhancements in cppyy`_, following are a few:
7272

73-
- **Reducing dependencies** of cppyy to minimize code bloat and make it
74-
faster.
75-
76-
- A **cppyy-Style Library** (i.e., CppInterOp) that enables interoperability
73+
1. **CppInterOp is a cppyy-inspired Library** that enables interoperability
7774
with C++ code, bringing the speed and efficiency of C++ to simpler, more
7875
interactive languages like Python.
7976

77+
2. **Reducing dependencies** of cppyy to minimize code bloat and make it
78+
faster.
79+
80+
3. **LLVM Integration**: CppInterOp's integration with LLVM's Clang-REPL
81+
component (that can then be used as a runtime compiler for CPPYY), will
82+
further enhance CPPYY's performance.
83+
84+
**CppInterOp is a cppyy-inspired Library**
85+
86+
A major use case for CppInterOp is the CPPYY service. CPPYY is an automatic
87+
run-time bindings generator for Python and C++, and supports a wide range of
88+
C++ features (e.g., template instantiation). It operates on demand and
89+
generates only what is necessary. It requires a compiler (Cling or Clang-REPL).
90+
that can be available during programme runtime.
91+
8092
**Reducing Dependencies**
8193

8294
Recent work done on cppyy has been focused on removing unnecessary
8395
dependencies on domain-specific infrastructure (e.g., the ROOT
8496
framework). The idea was to convert the cppyy-backend to use Cling
85-
directly (instead of ROOT meta), and then use it in cppyy.
97+
directly (instead of `ROOT meta`_), and then use it in cppyy.
8698

87-
Only a small set of APIs are needed to connect to the interpreter, since
88-
other APIs are already available in the standard compiler. This is what
89-
led to the creation of CppInterOp (a library of helper functions), that
90-
helped extract out things that were unnecessary for cppyy, etc.
99+
Only a small set of APIs are needed to connect to the interpreter (Cling),
100+
since other APIs are already available in the standard compiler. This is what
101+
led to the creation of CppInterOp (a library of helper functions), that helped
102+
extract out things that were unnecessary for cppyy, etc.
91103

92-
The API surface is now incomparably smaller and simpler than what it
93-
used to be.
94-
95-
**cppyy-Style Library**
96-
97-
The main use case for CppInterOp is the CPPYY service. CPPYY is an
98-
automatic run-time bindings generator for Python and C++, and supports a wide
99-
range of C++ features (e.g., template instantiation). It operates on demand and
100-
generates only what is necessary. It requires a compiler (Cling or Clang-REPL).
101-
that can be available during programme runtime.
104+
The cppyy API surface is now incomparably smaller and simpler than what it used
105+
to be.
102106

103107
**LLVM Integration**
104108

@@ -110,8 +114,8 @@ performance in the following ways:
110114
- *Simpler codebase:* The removal of string parsing logic will lead to a
111115
simpler code base.
112116

113-
- *LLVM Integration:* The CppInterOp interfaces will be part of the LLVM
114-
toolchain (as part of Clang-REPL).
117+
- *Built into the LLVM toolchain:* The CppInterOp interfaces will be part of
118+
the LLVM toolchain (as part of Clang-REPL).
115119

116120
- *Better C++ Support:* C++ features such as Partial Template Specialisation
117121
will be available through CppInterOp.
@@ -124,14 +128,14 @@ performance in the following ways:
124128

125129
**Making C++ More Social**
126130

127-
cppyy serves as a great proof of concept for other languages to become
128-
interoperable with C++ (using CppInterOp). This helps a lot of data
129-
scientists that are working with legacy C++ code and would like to
130-
migrate to simpler, more interactive languages.
131+
cppyy is the first use case demonstrating how CppInterOp can enable C++ to be
132+
more easily interoperable with other languages. This helps many data scientists
133+
that are working with legacy C++ code and would like to use simpler, more
134+
interactive languages.
131135

132-
The goal of this research is to eventually land these interoperability
133-
tools (including CppInterOp) to greater communities like LLVM and Clang,
134-
to enable C++ to interact with other languages besides Python.
136+
The goal of these enhancements is to eventually land these interoperability
137+
tools (including CppInterOp) to greater communities like LLVM and Clang, to
138+
enable C++ to interact with other languages besides Python.
135139

136140
Example: Template Instantiation
137141
-------------------------------
@@ -190,11 +194,29 @@ code.
190194
How cppyy components interact with each other
191195
---------------------------------------------
192196

193-
**cppyy-backend**
197+
cppyy is made up of the following packages:
198+
199+
- A frontend: cppyy,
194200

195-
The ``cppyy-backend`` forms a layer over ``cppyy``, modifying some
196-
functionality to provide the functions required for ``CPyCppyy``. It also adds
197-
some `utilities`_ to help with repackaging and redistribution.
201+
- A backend: cppyy-backend, and
202+
203+
- An extension: CPyCppyy.
204+
205+
Besides these, the ``CppInterOp`` library serves as an additional layer on top
206+
of Cling/Clang-REPL that helps these packages in communicating with C++ code.
207+
208+
**1. cppyy-backend**
209+
210+
The `cppyy-backend`_ pacakge forms a layer over ``cppyy``, for example,
211+
modifying some functionality to provide the functions required for
212+
``CPyCppyy``.
213+
214+
`CPyCppyy`_ is a CPython extension module built on top of the same backend
215+
API as PyPy/_cppyy. It thus requires the installation of the cppyy-backend
216+
for use, which will pull in Cling.
217+
218+
``cppyy-backend`` also adds some `utilities`_ to help with repackaging and
219+
redistribution.
198220

199221
For example, it initializes the interpreter (using the
200222
``clingwrapper::ApplicationStarter`` function), adds the required
@@ -205,22 +227,22 @@ CPyCppyy work.
205227
These changes help ensure that any change in ``cppyy`` doesn’t directly
206228
affect ``CPyCppyy``, and the API for ``CPyCppyy`` remains unchanged.
207229

208-
**CPyCppyy**
230+
**2. CPyCppyy**
209231

210-
``CPyCppyy`` uses the functionality provided by ``cppyy-backend`` and
211-
provides Python objects for C++ entities. ``CPyCppyy`` uses separate
212-
proxy classes for each type of object. It also includes helper classes,
213-
for example, ``Converters.cxx`` helps convert Python type objects to C++
214-
type objects, while ``Executors.cxx`` is used to execute a function and
215-
convert its return value to a Python object, so that it can be used
216-
inside Python.
232+
The ``CPyCppyy`` package uses the functionality provided by ``cppyy-backend``
233+
and provides Python objects for C++ entities. ``CPyCppyy`` uses separate proxy
234+
classes for each type of object. It also includes helper classes, for example,
235+
``Converters.cxx`` helps convert Python type objects to C++ type objects, while
236+
``Executors.cxx`` is used to execute a function and convert its return value to
237+
a Python object, so that it can be used inside Python.
217238

218-
**cppyy**
239+
**3. cppyy**
219240

220-
cppyy provides the front-end for Python. It is `included`_ in code to import
221-
cppyy in Python. It initializes things on the backend side, provides helper
222-
functions (e.g., ``cppdef()``, ``cppexec()``, etc.) that the user can utilize,
223-
and it calls the relevant backend functions required to initialize cppyy.
241+
The cppyy package provides the front-end for Python. It is `included in code`_
242+
(using ``import cppyy``) to import cppyy in Python. It initializes things on
243+
the backend side, provides helper functions (e.g., ``cppdef()``, ``cppexec()``,
244+
etc.) that the user can utilize, and it calls the relevant backend functions
245+
required to initialize cppyy.
224246

225247

226248
Further Reading
@@ -243,28 +265,43 @@ Further Reading
243265

244266
**Credits:**
245267

246-
- `Baidyanath Kundu <https://github.com/sudo-panda>`_ (Princeton
247-
University) for his research work on cppyy and Numba for `Compiler
248-
Research Organization <https://compiler-research.org/>`_.
249-
250-
- `Vassil Vasilev <https://github.com/vgvassilev>`_ (Princeton
251-
University) for mentoring Baidyanath and continuing this research
252-
with `Aaron Jomy <https://github.com/maximusron>`_.
268+
- `Wim Lavrijsen <https://github.com/wlav>`_ (Lawrence Berkeley National Lab.)
269+
for his original work in cppyy and mentorship towards student contributors.
253270

254-
- `Wim Lavrijsen <https://github.com/wlav>`_ (Lawrence Berkeley
255-
National Lab) cppyy’s original contributor.
271+
- `Vassil Vasilev <https://github.com/vgvassilev>`_ (Princeton University)
272+
for his mentorship towards Compiler Research Org's student contributors.
256273

274+
- `Baidyanath Kundu <https://github.com/sudo-panda>`_ (Princeton University)
275+
for his research work on cppyy and Numba with `Compiler Research Organization`_
276+
(as discussed in this document).
277+
278+
- `Aaron Jomy <https://github.com/maximusron>`_ (Princeton University) for
279+
continuing this research work with `Compiler Research Organization`_.
257280

258281
In case you haven't already installed CppInterop, please do so before proceeding
259282
with the Installation And Usage Guide.
260283
:doc:`Installation and usage <InstallationAndUsage>`
261284

285+
.. _Compiler Research Organization: https://compiler-research.org/
286+
262287
.. _upstream cppyy: https://github.com/wlav/cppyy
263288

264289
.. _wlav: https://github.com/wlav
265290

266291
.. _utilities: https://cppyy.readthedocs.io/en/latest/utilities.html
267292

268-
.. _included: https://cppyy.readthedocs.io/en/latest/starting.html
293+
.. _included in code: https://cppyy.readthedocs.io/en/latest/starting.html
294+
295+
.. _sudo-panda: https://github.com/sudo-panda
296+
297+
.. _cppyy: https://cppyy.readthedocs.io/en/latest/index.html
298+
299+
.. _CppInterOp: https://github.com/compiler-research/CppInterOp
300+
301+
.. _ROOT meta: https://github.com/root-project/root/tree/master/core/meta
302+
303+
.. _enhancements in cppyy: https://arxiv.org/abs/2304.02712
304+
305+
.. _CPyCppyy: https://github.com/wlav/CPyCppyy
269306

270-
.. _sudo-panda: https://github.com/sudo-panda
307+
.. _cppyy-backend: https://github.com/wlav/cppyy-backend

0 commit comments

Comments
 (0)