- Can I create my own functions in C?
- ===================================
- Yes, you can create built-in modules containing functions, variables, exceptions and even new types in C. This is explained in the document
- Extending and Embedding the Python Interpreter.
- Most intermediate or advanced Python books will also cover this topic.
- Can I create my own functions in C++?
- =====================================
- Yes, using the C compatibility features found in C++. Place "extern
- "C" { ... }" around the Python include files and put "extern "C""
- before each function that is going to be called by the Python
- interpreter. Global or static C++ objects with constructors are
- probably not a good idea.
- Writing C is hard; are there any alternatives?
- ==============================================
- There are a number of alternatives to writing your own C extensions,
- depending on what you're trying to do.
- Cython and its relative Pyrex are compilers that accept a slightly
- modified form of Python and generate the corresponding C code. Cython
- and Pyrex make it possible to write an extension without having to
- learn Python's C API.
- If you need to interface to some C or C++ library for which no Python
- extension currently exists, you can try wrapping the library's data
- types and functions with a tool such as SWIG. SIP, CXX Boost, or
- Weave are also alternatives for wrapping C++ libraries.
- Watch: Extending Python With C
Python software and documentation are licensed under the PSF License Agreement.
Starting with Python 3.8.6, examples, recipes, and other code in the documentation are dual licensed under the PSF License Agreement and the Zero-Clause BSD license.
Some software incorporated into Python is under different licenses. The licenses are listed with code falling under that license. See Licenses and Acknowledgements for Incorporated Software for an incomplete list of these licenses.
Python and it's documentation is:
Copyright © 2001-2022 Python Software Foundation. All rights reserved.
Copyright © 2000 BeOpen.com. All rights reserved.
Copyright © 1995-2000 Corporation for National Research Initiatives. All rights reserved.
Copyright © 1991-1995 Stichting Mathematisch Centrum. All rights reserved.
See History and License for complete license and permissions information:
https://docs.python.org/3/license.html#psf-license