Top secret .NET handles – Part 1 – Dependent handles

.NET publicly has documented 4 kind of handles: Weak (also called Short Weak) – Don’t keep target object alive and will return null when object is gone. The target will become null when the object enters for finalization. WeakTrackResurrection (also called Long Weak) – Don’t keep target object alive and will return null when object is gone….

0

Calling C functions from Python – part 3 – deep dive into ctypes implementation in CPython

Last time we’ve looked at using ctypes to call C API, and writing extension module using Python/C API. Now we can finally tie these two together – looking at how ctypes is actually implemented using mix of Python/C API and Python code. You can find CPython source code here. ctypes’ C implementation is here ctypes’ python implementation…

0

Calling C functions from Python – part 2 – writing CPython extensions using Python/C API

In my previous post we’ve briefly looked at using ctypes module to call C APIs. In this post let’s dive into a completely different approach – writing a C extension using Python/C API. From the C extension you can then call whatever C/C++ code you want. This is a pretty popular approach to expose a 3rd party…

0

Calling C functions from Python – part 1 – using ctypes

Recently I’ve been evaluating Python interop technologies for a project at work and I think it’ll made an interesting blog series. Let’s say your have following C code (add extern “C” if you are in C++ land) and compile it into a dynamic library (dll/.so/.dylib): int Print(const char *msg) { printf(“%s”, msg); return 0; } int Add(int…

0

Calling node.js sqlite callback function using promise and await

Callback pain I was experimenting with sqlite package with node.js the other day and the async programming style is rather painful, so I did some experiment to wrap it with promise + async/await to make it easier to use. This post shows you how to do that. For example, let’s say I’m working with a database with…

0