An example of ctypes on IronPython? - mono

I'm trying to understand ctypes, and it's relationship to IronClad, on IronPython. (Ctypes is supposed to be implemented in the latest IronPython release.) Can somebody give a simple example of ctypes in IronPython that works on Mono/OSX? When trying the standard demos, I get:
import ctypes
SystemError: libdl.so
Am I missing something obvious?
More generally, how does ctypes relate to the IronClad project?

I don't know the answer to your first question (I don't use Mono - sorry), but I can answer your general question.
IronClad is an adaptor that allows existing CPython extension modules, written against the CPython API, to work seamlessly on IronPython. Ctypes, on the other hand, is an FFI (Foreign Function Interface) that allows Python code to call into native code in a platform-independent way.
Before ctypes, the only way to access native code from Python was to write a CPython extension that was tightly coupled to CPython; ctypes removes that coupling and allows it to work on any Python implementation that implements ctypes. IronClad exists to allow all of the legacy extensions to continue to work on IronPython. For new stuff, though, ctypes is the way to go.

Related

using different programming language in godot game engine?

I want to bind a different programming language to the Godot game engine. Is there an instructional document or video on this topic? For example, how was this project done: godot-rust. If I can learn the basics, I can succeed in working in a different language. Thanks.
In this answer I show you the different approaches to add language support in Godot 3.x (the situation will be somewhat different with Godot 4.0 and GDExtension - which replaces GDNative and hopefully means less custom builds), and I mention some languages that are supported by each of these approaches. However, this is not an exhaustive list of the languages.
First of all, Godot has official build-in support for GDScript and Godot's VisualScript (and Godot's shading language and its visual counterpart if those counts for you).
There are a few ways to use C++:
You can use it to create GDNative scripts (which are basically a wrapper around native calls that allow you to use them as scripts in Godot).
Or you can create modules (which are static libraries you can add in a custom Godot build).
And since Godot source is in C++, you don't have to restrict yourself to making modules if you are making custom builds.
In web builds Godot can interface with JavaScript via the JavaScript class. However, this approach does not allow you to add JavaScript scripts to Nodes, and so on.
Then there are languages that can only be added in custom builds of Godot, which is currently the official support for C#.
There are other non-official custom builds that offer language binding for languages such as Lua, Kotlin, TypeScript and JavaScript (this time allowing you to make scripts).
If you need to add a runtime, you would probably do this.
Some language take advantage of the fact that Godot's has official Mono support in order to support C#. This way you can, for example, use F# and Clojure.
They start by adding a C# project and then modify it so it uses another language. This is viable if your language already compiles to .NET.
Some other languages can be added as plugins that implement the PluginScript class via GDNative. This is the case of Python and Lua (again) which you can get from the asset library.
This is the most user friendly way to add language support to Godot, but it is limited to what you can do with PluginScript.
Addendum: Gil Barbosa Reis, author of the aforementioned Lua bindings, has an article series about its implementation stuffed away in the repository (in English and Portugueses): godot-lua-pluginscript/extras/articles/. It is probably the most comprehensive tutorial to date.
Other languages are added by means of taking advantage of GDNative (They basically mimic what you would do with C++). This is the case of Nim, Rust, D, Haskell, Go, Swift…
So that's how godot-rust works: make native libraries using rust and the godot-rust create and add them as if they were made in C++. For any language for which there are the means to make native libraries already, this is a good option.
Finally there is another way to add support for a language: a transpiler from that language to GDScript, which can be automated with an addon that might also be written in GDScript. This is the case of Lisp.
This last approach is mostly used for domain specific languages.
The official docs here provide your answer:
Godot officially supports GDScript, C/C++, C#.
Some 3rd party languages that can be used are: Rust, D, Python, Nim, and Go.

How MapDataset captures user defined function from Python and inject into C++ implementation

I am getting started with TF and I am interested in 1) learning how tf.data implementation works, in particular, on how the C++ backend captures/executes user defined-function by Python scripts.
I was expecting that C++ backend would use Python embedded approach, but apparently this doesnt happen; maybe because of performance hits in instantiating python interpreters on c++ for each example/batch. Instead, tf.data seems to transform user-defined functions by Python scripts in graphs on the C++ side, as mentioned in this great video by TF folks at 5:15.
I have been trying to make sense of python/ops/gen_dataset_ops.py, tensorflow/core/ops/dataset_ops.cc, tensorflow/core/kernels/data/map_dataset_op.cc, tensorflow/core/framework/function.h, ``tensorflow/core/kernels/data/captured_function.h` without success. Any pointer on how to understand this flow would be truly appreciated!
Assuming user-defined functions are transformed in c++ graphs, 2) does that mean that the user-defined function must use only native python operations or python classes/modules could also be used and "somehow" converted into C++?

Can I use a normal dll or another language package in Ada?

Currently I am using a hardware that provides me a software package that comes from a DLL. They also provide packages in different languages (Java, C++ and Python) with functions from the DLL, so I am programming my app in Java. I would like to change to Ada but I don't know the way to use the DLL functions or the packages that the company offer me in other languages. Is there a way to do it?
I know I can extract the function names from the DLL, but I don't exactly know how to convert that into an Ada package, or if I can use the packages already made in other languages in any way.
The lazy answer is simply "yes". :-)
The GCC documentation on the subject is here: https://gcc.gnu.org/onlinedocs/gnat_ugn/Using-DLLs-with-GNAT.html
As it says, you also need an Ada specification for the functions in the DLL, you want to use. You can either write it by hand, or use gcc -fdump-ada-spec on the C or C++ header files to have one generated automatically. The generated specifications are not always beautiful, but they are more likely to be correct than something you write from scratch yourself.

What interpreters have been made using the PyPy Translator Toolchain?

What interpreters have been made using the PyPy Translator Toolchain besides PyPy itself?
The two most complete (besides the Python one) are Javascript and Prolog, but there are also Squeak, Scheme, Brainfuck, and Haskell in various levels of completeness.

How can we use python module in vb.net

I want to use the python module imaplib, email in vb.net to read the gmail email with attachments. How can i use the python module in vb.net
Presuming you already looked at Brad's suggestion and didn't find it quite satisfying there is a .Net module for handling python, although this seems like the inverse of what you're looking for.
The only way that you could realistically use a Python library in .NET is to use IronPython. It is possible to embed IronPython in a C# app and the best explanation of that is in the book IronPython in Action.
However, this introduces a lot of layers in an application and may not be the wisest way to go unless you can make use of a general scripting language in your app.