Skip to content

Instantly share code, notes, and snippets.

View lrq3000's full-sized avatar
🎵

Stephen Karl Larroque lrq3000

🎵
View GitHub Profile
@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

@jtriley
jtriley / terminalsize.py
Created July 26, 2011 21:58
Get current terminal size on Linux, Mac, and Windows
#!/usr/bin/env python
import os
import shlex
import struct
import platform
import subprocess
def get_terminal_size():
""" getTerminalSize()
@bellbind
bellbind / relimporter.py
Created July 26, 2010 14:33
[python] __import__ by relative module style
def import_as(module_name, globals_):
"""__import__ for relative module style.
usage:
mod = import_as("..templates.jinja2", globals())
# it is same as: import ..templates.jinja2 as mod
"""
level = 0
for ch in module_name:
if ch != ".": break
level += 1