Skip to content

Instantly share code, notes, and snippets.

@njsmith
njsmith / sequence.py
Created May 15, 2015 07:45
Describing the behavior of CPython `list` etc. in pure Python
# Attempt to implement in pure Python a Sequence class which behaves the same
# way as a CPython object that provides tp_as_sequence but not
# tp_as_number (like, for example, the built-in types list, tuple, ...).
def _proper_subinstance(a, b):
ta = type(a)
tb = type(b)
return ta is not tb and issubclass(ta, tb)
class Sequence(object):
N = 100
x = np.linspace(0, 1, N)
jet_samples_sRGB = jet(x)
jet_samples_Jpapbp = cspace_convert(jet_samples_sRGB, "sRGB1", "CAM02-UCS")
distances = np.cumsum(np.sqrt(np.sum((jet_samples_Jpapbp[:-1, ...] - jet_samples_Jpapbp[1:, ...]) ** 2), axis=-1))
distances = np.concatenate(([0], distances))
newjet_samples_Jpapbp = np.interp(x, distances, jet_samples_Jpapbp)
newjet_samples_sRGB = cspace_convert(newjet_samples_Jpapbp, "CAM02-UCS", "sRGB1")
$ conda create -n anaconda-34 python=3.4 anaconda
<output elided -- I ended up with anaconda 2.3.0 npy19py34_0>
$ source activate anaconda-34
# This is a list of every package they link to outside of what they ship, but see below:
~$ find miniconda/envs/anaconda-34 -name '*.so' | xargs -n1 ldd | grep -v miniconda | cut -f1 -d' ' | sort -u
/lib64/ld-linux-x86-64.so.2
libcrypt.so.1
libc.so.6
@njsmith
njsmith / future-of-numpy-bof.odp
Last active August 29, 2015 14:28
Slides from "Future of NumPy" BoF at SciPy 2015
#!python
import sys
import time
import ctypes
import ctypes.wintypes
import subprocess
GetCurrentProcess = ctypes.windll.kernel32.GetCurrentProcess
GetCurrentProcess.argtypes = []
@njsmith
njsmith / ipython-4.0.0 wheel METADATA
Last active November 7, 2015 04:56
METADATA files from some real wheels
Metadata-Version: 2.0
Name: ipython
Version: 4.0.0
Summary: IPython: Productive Interactive Computing
Home-page: http://ipython.org
Author: The IPython Development Team
Author-email: ipython-dev@scipy.org
License: BSD
Download-URL: https://github.com/ipython/ipython/downloads
Keywords: Interactive,Interpreter,Shell,Parallel,Distributed,Web-based computing,Qt console,Embedding
import sys
import os
import os.path
import subprocess
import json
# entry point for 'python -m pip'
def python_m_pip_main():
do_pip(sys.argv)
# Sample usage (with hypothetical build_wheel method that returns the name of the built wheel):
# wheel_name = call_build_system("build/tmp", "build/tmp/venv/bin/python",
# "flit:build_system_api",
# "build_wheel", output_dir)
import json
import pkg_resources
from pip.utils import call_subprocess
@njsmith
njsmith / ucrt-csv.py
Last active April 6, 2024 18:04
Information on linking to the new Windows UCRT
import sys
import subprocess
import csv
def describe_ucrt_lib(platform):
lib_path = "windows-10-sdk/Lib/10.0.10240.0/ucrt/{}/ucrt.lib".format(platform)
output = subprocess.check_output(["nm", lib_path])
output = output.decode("utf-8")
# Output (x86 32-bit) looks like:
Version symbols section '.gnu.version' contains 543 entries:
Addr: 0000000000005354 Offset: 0x005354 Link: 3 (.dynsym)
000: 0 (*local*) 0 (*local*) 1a (GLIBC_2.2.5) 1b (NCURSES_TINFO_5.7.20081102)
004: 1a (GLIBC_2.2.5) 1a (GLIBC_2.2.5) 1c (NCURSES_TINFO_5.0.19991023) 1a (GLIBC_2.2.5)
008: 1a (GLIBC_2.2.5) 1c (NCURSES_TINFO_5.0.19991023) 0 (*local*) 1a (GLIBC_2.2.5)
00c: 1c (NCURSES_TINFO_5.0.19991023) 1a (GLIBC_2.2.5) 1a (GLIBC_2.2.5) 1d (NCURSES_TINFO_5.8.20110226)
010: 1c (NCURSES_TINFO_5.0.19991023) 1a (GLIBC_2.2.5) 1b (NCURSES_TINFO_5.7.20081102) 1a (GLIBC_2.2.5)
014: 1c (NCURSES_TINFO_5.0.19991023) 1a (GLIBC_2.2.5) 1a (GLIBC_2.2.5) 1a (GLIBC_2.2.5)
018: 1c (NCURSES_TINFO_5.0.19991023) 1c (NCURSES_TINFO_5.0.19991023) 1c (NCURSES_TINFO_5.0.19991023) 1a (GLIBC_2.2.5)