Skip to content

Instantly share code, notes, and snippets.

View gdementen's full-sized avatar

Gaëtan de Menten gdementen

  • Federal Planning Bureau
  • Belgium
View GitHub Profile
@ogrisel
ogrisel / numpy_pickle_protocol_5.py
Last active October 13, 2019 09:17
Draft use of pickle protocol 5 (PEP 574) for zero-copy numpy array pickling
from pickle import Pickler, load
try:
from pickle import PickleBuffer
except ImportError:
PickleBuffer = None
import copyreg
import os
import numpy as np
import time
@dagss
dagss / gist:5008118
Last active September 20, 2017 01:33
marked_yaml
"""
A PyYAML loader that annotates position in source code.
The loader is based on `SafeConstructor`, i.e., the behaviour of
`yaml.safe_load`, but in addition:
- Every dict/list/unicode is replaced with dict_node/list_node/unicode_node,
which subclasses dict/list/unicode to add the attributes `start_mark`
and `end_mark`. (See the yaml.error module for the `Mark` class.)