{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "there is an IPython magic for CFFI: https://github.com/Carreau/cffi_magic\n", "\n", "https://tmarkovich.github.io//articles/2017-08/linking-python-to-c-with-cffi" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "these are just some random experiments ..." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from cffi import FFI\n", "ffi = FFI()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ffi.cdef(\"\"\"\n", "typedef void mytype;\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ptrptr = ffi.new(\"mytype**\")\n", "ptrptr" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "type(ptrptr)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ptrptr[0]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ptrptr[0] += 1\n", "ptrptr[0]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ptr = ptrptr[0]\n", "ptr" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "type(ptr)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`ptr` is a separate, non-owning cdata object. It is not pointing to the original data." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ptr += 1\n", "ptr" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ptrptr[0]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "del ptrptr" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ptr" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n",
" \n",
"
\n",
" \n",
"
\n",
" To the extent possible under law,\n",
" the person who associated CC0\n",
" with this work has waived all copyright and related or neighboring\n",
" rights to this work.\n",
"