Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I create a Python extension module in D (instead of C)

Tags:

python

module

d

I hear D is link-compatible with C. I'd like to use D to create an extension module for Python. Am I overlooking some reason why it's never going to work?

like image 295
Jonathan Hartley Avatar asked Jul 19 '09 15:07

Jonathan Hartley


People also ask

Are Python modules written in C?

Most of the Python Libraries are written in the C programming language.

What is C extension in Python?

Any code that you write using any compiled language like C, C++, or Java can be integrated or imported into another Python script. This code is considered as an "extension." A Python extension module is nothing more than a normal C library. On Unix machines, these libraries usually end in . so (for shared object).

Is C compatible with Python?

Python code can make calls directly into C modules. Those C modules can be either generic C libraries or libraries built specifically to work with Python.

What is the standard extension for Python modules?

You'll need a file called setup.py to install your application. For this tutorial, you'll be focusing on the part specific to the Python C extension module.

How to write a simple C extension module in Python?

Writing a simple C extension module directly using Python’s extension API and no other tools. It is straightforward to make a handcrafted extension module for a simple C code. But first, we have to make sure that the C code has a proper header file. The header would correspond to a library that has been separately compiled.

How to extend Python with C or C++?

1. Extending Python with C or C++ ¶ It is quite easy to add new built-in modules to Python, if you know how to program in C. Such extension modules can do two things that can’t be done directly in Python: they can implement new built-in object types, and they can call C library functions and system calls.

Is it possible to program in Python from c?

It is quite easy to add new built-in modules to Python, if you know how to program in C. Such extension modules can do two things that can’t be done directly in Python: they can implement new built-in object types, and they can call C library functions and system calls.

How to raise Python exceptions from C extension module?

If you want to raise Python exceptions from your C extension module, then you can use the Python API to do so. Some of the functions provided by the Python API for exception raising are as follows: Takes two arguments: a PyObject * type argument specifying the type of exception, and a custom message to display to the user


1 Answers

Wait? Something like this http://www.dsource.org/projects/pyd (previously http://pyd.dsource.org/)

like image 199
Wojciech Bederski Avatar answered Sep 20 '22 13:09

Wojciech Bederski