Skip to content

Instantly share code, notes, and snippets.

View jakebolewski's full-sized avatar
🌨️
⛷️

Jake Bolewski jakebolewski

🌨️
⛷️
View GitHub Profile
(defn ensure-initialized [p]
(or (deref p 0 nil) (throw (IllegalStateException. "Method called on half-initialized object."))))
(defmacro reify-let
[name bindings & impls]
(let [p (gensym "p")
delegate (fn [x]
(if (seq? x)
(let [[method args] x]
`(~method ~args (~method (ensure-initialized ~p) ~@(next args))))
@GaelVaroquaux
GaelVaroquaux / 00README.rst
Last active December 13, 2024 15:53
Copy-less bindings of C-generated arrays with Cython

Cython example of exposing C-computed arrays in Python without data copies

The goal of this example is to show how an existing C codebase for numerical computing (here c_code.c) can be wrapped in Cython to be exposed in Python.

The meat of the example is that the data is allocated in C, but exposed in Python without a copy using the PyArray_SimpleNewFromData numpy