Skip to content

Instantly share code, notes, and snippets.

View joocer's full-sized avatar

Justin Joyce joocer

View GitHub Profile
@joocer
joocer / lru_k.py
Created September 14, 2022 14:05
LRU-K implementation in Python
"""
LRU-K evicts the page whose K-th most recent access is furthest in the past.
This is a basic implementation of LRU-2, which evicts entries according to the time
of their penultimate access. The main benefit of this approach is to prevent
a problem when the items being checked exceeds the number of items in the cache. A
classic LRU will evict and repopulate the cache for every call. LRU-2 reduces the
likelihood of this, but not preferring the MRU item to be retained.
LRU-K should be used in conjunction with eviction limits per query - this appears to
@joocer
joocer / memory_pool.pyx
Last active March 24, 2025 03:02
cython memory pool
# cython: language_level=3
# cython: nonecheck=False
# cython: cdivision=True
# cython: initializedcheck=False
# cython: infer_types=True
# cython: wraparound=True
# cython: boundscheck=False
"""
This is a Cython memory pool, it reserves a block of memory and supports reading and writing
@joocer
joocer / test_tools.py
Created June 15, 2024 13:19
Python Testing Helper
"""
Test Harness
This module provides a set of utility functions and decorators to assist with
conditional test execution, platform-specific checks, and test result reporting
when running pytest tests locally.
It includes functionality to:
- Check the platform and Python implementation (e.g., ARM architecture, Windows, macOS, PyPy).