Skip to content

Instantly share code, notes, and snippets.

Avatar

Wu Yongwei adah1972

View GitHub Profile
@adah1972
adah1972 / ordering.cpp
Created Dec 22, 2019
Intel CPU reordering example made to work on macOS
View ordering.cpp
// 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 Jul 22, 2019
Decorator for using dicts/lists with any Python cache function (like lru_cache)
View hashable_cache.py
# Inspired by https://gist.github.com/harel/9ced5ed51b97a084dec71b9595565a71
from collections import namedtuple
import functools
import json
import six
Serialized = namedtuple('Serialized', 'json')
You can’t perform that action at this time.