Skip to content

Instantly share code, notes, and snippets.

View nitzmahone's full-sized avatar

Matt Davis nitzmahone

View GitHub Profile
@nitzmahone
nitzmahone / output.txt
Created September 30, 2024 17:27
Type instance micro-benchmark comparison
TL;DR: use isinstance for subclass-friendly type checks unless microperf is needed, then use type is or type in (set) as needed
Timings on 3.11-3.13
3.11:
wrong: 0.01907933602342382s
isinstance: 0.03639550699153915s
isinstance (multiple types tuple): 0.0790955779957585s
in set: 0.05437163001624867s
import importlib
import os
import pkgutil
import sys
from pathlib import Path
# note these are the loader attribute prefix names from loader.py, we convert them later to the collection loader plugin type values
PLUGIN_TYPES = ['module', 'become', 'cache', 'callback', 'connection', 'shell', 'inventory']