Skip to content

Instantly share code, notes, and snippets.

View adah1972's full-sized avatar

Wu Yongwei adah1972

View GitHub Profile
@adah1972
adah1972 / ordering.cpp
Created December 22, 2019 14:53
Intel CPU reordering example made to work on macOS
// Jeff Preshing's example that shows the reordering of Intel CPUs made to
// work on both Linux and macOS.
//
// Original source:
//
// https://preshing.com/20120515/memory-reordering-caught-in-the-act/
//
// Apple semaphore change is based on the answer by dho at:
//
// https://stackoverflow.com/questions/27736618/why-are-sem-init-sem-getvalue-sem-destroy-deprecated-on-mac-os-x-and-w
@adah1972
adah1972 / hashable_cache.py
Last active July 31, 2023 17:00
Decorator for using dicts/lists with any Python cache function (like lru_cache)
# Inspired by https://gist.github.com/harel/9ced5ed51b97a084dec71b9595565a71
from collections import namedtuple
import functools
import json
import six
Serialized = namedtuple('Serialized', 'json')