gaskill

gaskill/gaskill/__init__.py
Core namespace aggregator. Imports all public symbols from submodules.
核心命名空间聚合器。从子模块导入所有公共符号。

Imported Symbols / 导入的符号

All public symbols from the following modules are imported into the gaskill namespace:
以下模块的所有公共符号被导入到 gaskill 命名空间:
smath Core math functions, constants, Complex class核心数学函数、常量、Complex 类
sfrac Frac class for exact rational arithmeticFrac 类用于精确有理数运算
svector vec2, vec3, vec4 vector classesvec2、vec3、vec4 向量类
smatrix Matrix class with linear algebra operationsMatrix 矩阵类,含线性代数运算
squaternion Quaternion class for 3D rotations四元数类,用于 3D 旋转
srandom Random number generator with dice support随机数生成器,支持骰子
scolor Color manipulation and constants颜色操作和常量
sgeometry 2D geometry: Polygon, Rect, Circle, Line22D 几何:多边形、矩形、圆、线段
sgeometry3d 3D geometry: AABB, Ray, Sphere, Plane3D 几何:AABB、射线、球体、平面
scurve Curves: Bezier, B-spline, NURBS曲线:贝塞尔、B样条、NURBS
seasing Easing functions for animation动画缓动函数
sinterp Interpolation functions插值函数
scache Cache data structures: LRU, LFU, TTL缓存数据结构:LRU、LFU、TTL
sevent Event system with listeners事件系统,含监听器
sfsm Finite State Machine有限状态机
spool Object pool and stack allocator对象池和栈分配器
spathfinder Pathfinding: A*, Dijkstra, BFS, flow field寻路:A*、Dijkstra、BFS、流场
ssaver Save/Load system with hash verification存档/读档系统,含哈希校验
sformat String formatting utilities字符串格式化工具
snoise Perlin, Simplex, and point-based noisePerlin、Simplex 和基于点的噪声
scrypt Cryptography: RSA, secret sharing加密:RSA、秘密共享
solver Equation solvers方程求解器
sstat Statistics functions统计函数
sbase64 Base16/32/64/58/256 encodingsBase16/32/64/58/256 编码
sabc Abstract Base Class support抽象基类支持
spickle Binary serialization二进制序列化
type Type utilities: DefaultDict, ABC bases类型工具:DefaultDict、ABC 基类
sha256 (message: bytes) -> str SHA-256 hash digestSHA-256 哈希摘要
DJB2 (s: str, capacity: int = 0xffffffff) -> int DJB2 hash functionDJB2 哈希函数

_roll

gaskill/gaskill/_roll.py
Dice notation parser and roller. Used internally by srandom.Random.roll().
骰子表达式解析器和掷骰器。由 srandom.Random.roll() 内部使用。
parse_dice (expr: str) -> dict
Parse a dice expression into a structured dictionary.
将骰子表达式解析为结构化字典。
Params: expr - Dice expression string
参数:expr - 骰子表达式字符串
Returns: dict with 'expr', 'parts', 'total'
返回:包含 'expr'、'parts'、'total' 的字典
roll_dice (parse_result: dict, random_func: callable) -> int
Roll dice based on a parsed result.
根据解析结果掷骰子。
Params: parse_result - From parse_dice; random_func - Function returning random int
参数:parse_result - parse_dice 的结果;random_func - 返回随机整数的函数
Returns: Total rolled value
返回:掷骰总结果
get_dice_info (expr: str) -> dict
Return metadata about a dice expression.
返回骰子表达式的元信息。
Params: expr - Dice expression
参数:expr - 骰子表达式
Returns: dict with 'expr', 'dice_count', 'total_sides', etc.
返回:包含 'expr'、'dice_count'、'total_sides' 等的字典

sabc

gaskill/gaskill/sabc.py
Abstract Base Class (ABC) implementation with virtual subclass support.
抽象基类(ABC)实现,支持虚拟子类。

ABCMeta

class ABCMeta(type)
Metaclass for defining Abstract Base Classes.
定义抽象基类的元类。
__new__ (cls, name, bases, dct)
Create a new class. Collects abstract methods and initializes caches.
创建新类。收集抽象方法并初始化缓存。
__call__ (cls, *args, **kwargs)
Prevents instantiation if abstract methods remain.
如果还有抽象方法,阻止实例化。
__subclasscheck__ (cls, subclass)
Controls issubclass() behavior with caching and hooks.
控制 issubclass() 行为,含缓存和钩子。
__instancecheck__ (cls, instance)
Controls isinstance() behavior.
控制 isinstance() 行为。
register (cls, subclass)
Register a virtual subclass.
注册虚拟子类。

ABC

class ABC(metaclass=ABCMeta)
Base class for Abstract Base Classes.
抽象基类的基类。
abstractmethod (func)
Decorator marking a method as abstract.
装饰器,将方法标记为抽象。
abstractclassmethod (func)
Decorator for abstract class methods.
抽象类方法装饰器。
abstractstaticmethod (func)
Decorator for abstract static methods.
抽象静态方法装饰器。
abstractproperty (func)
Decorator for abstract properties.
抽象属性装饰器。

sbase64

gaskill/gaskill/sbase64.py
Base16, Base32, Base64, Base64URL, Base58, and Base256 (Chinese) encodings.
Base16、Base32、Base64、Base64URL、Base58 和 Base256(中文)编码。
BASE16_ALPHABET BASE32_ALPHABET BASE64_ALPHABET BASE64URL_ALPHABET BASE58_ALPHABET
b16encode (data: bytes) -> bytes
Encode to Base16 (hexadecimal).
编码为 Base16(十六进制)。
b16decode (data: bytes) -> bytes
Decode from Base16.
从 Base16 解码。
b32encode (data: bytes) -> bytes
Encode to Base32.
编码为 Base32。
b32decode (data: bytes) -> bytes
Decode from Base32.
从 Base32 解码。
b64encode (data: bytes) -> bytes
Encode to Base64.
编码为 Base64。
b64decode (data: bytes) -> bytes
Decode from Base64.
从 Base64 解码。
b64urlencode (data: bytes) -> bytes
Encode to Base64URL (URL-safe).
编码为 Base64URL(URL 安全)。
b64urldecode (data: bytes) -> bytes
Decode from Base64URL.
从 Base64URL 解码。
b58encode (data: bytes) -> bytes
Encode to Base58 (Bitcoin alphabet).
编码为 Base58(比特币字母表)。
b58decode (data: bytes) -> bytes
Decode from Base58.
从 Base58 解码。
b256encode (data: bytes) -> bytes
Encode to Base256 using Chinese characters.
使用中文字符编码为 Base256。
b256decode (data: bytes) -> bytes
Decode from Base256 (Chinese).
从 Base256(中文)解码。

scache

gaskill/gaskill/scache.py
Caching data structures: LFU, LRU, TTL, memoization, RingBuffer, and CacheStats.
缓存数据结构:LFU、LRU、TTL、记忆化、环形缓冲区和缓存统计。

LFUCache

class LFUCache(max_size: int = 100)
Least Frequently Used cache.
最少使用缓存。
get (key, default=None)
Get value, increments access count.
获取值,增加访问计数。
set (key, value)
Store value, evicts LFU item if full.
存储值,满时淘汰最少使用项。
pop (key, default=None)
Remove and return value.
移除并返回值。
clear ()
Clear all items.
清空所有项。
keys () -> list
All keys.
所有键。
values () -> list
All values.
所有值。
items () -> list
All key-value pairs.
所有键值对。
size (property)
Current number of items.
当前项数。
max_size (property)
Maximum capacity.
最大容量。

LRUCache

class LRUCache(max_size: int = 100)
Least Recently Used cache.
最近最少使用缓存。
get (key, default=None)
Get value, moves to most recent.
获取值,移到最近使用位置。
set (key, value)
Store value, evicts LRU if full.
存储值,满时淘汰最近最少使用项。
pop (key, default=None)
clear ()
keys () -> list
values () -> list
items () -> list
size (property)
max_size (property)

CacheEntry

class CacheEntry(key, value, ttl: int = 0)
is_expired (current_time: int) -> bool
Check if entry has expired.
检查条目是否已过期。

TTLCache

class TTLCache(max_size: int = 100, default_ttl: int | None = None)
Time-to-live cache with expiration.
带过期时间的缓存。
get (key, default=None, current_time=0)
Get value, removes if expired.
获取值,过期则移除。
set (key, value, ttl=0, current_time=0)
Store with TTL.
带 TTL 存储。
clear ()
remove_expired (current_time: int) -> int
Remove all expired entries.
移除所有过期条目。
size (property)

RingBuffer

class RingBuffer(capacity: int)
Fixed-size FIFO buffer.
固定大小 FIFO 缓冲区。
push (item)
Add item, overwrites oldest if full.
添加项,满时覆盖最旧项。
pop ()
Remove and return oldest.
移除并返回最旧项。
peek ()
Return oldest without removing.
返回最旧项但不移除。
clear ()
is_empty () -> bool
is_full () -> bool
capacity (property)

CacheStats

class CacheStats()
Cache hit/miss/eviction statistics.
缓存命中/未命中/淘汰统计。
record_hit ()
Record a cache hit.
记录缓存命中。
record_miss ()
Record a cache miss.
记录缓存未命中。
record_eviction ()
Record a cache eviction.
记录缓存淘汰。
reset ()
Reset all statistics.
重置所有统计。
hits (property)
misses (property)
evictions (property)
total_requests (property)
hit_rate (property) -> float
memoize (max_size: int = 128, method: bool = False) -> callable
Decorator for function/method memoization.
函数/方法记忆化装饰器。
Params: max_size - Cache size; method - If True, skips self
参数:max_size - 缓存大小;method - 为 True 时跳过 self

scolor

gaskill/gaskill/scolor.py
Color manipulation: RGB/HSV conversion, blending, gradients, luminance, contrast, deltaE, etc.
颜色操作:RGB/HSV 转换、混合、渐变、亮度、对比度、deltaE 等。
WHITE BLACK RED GREEN BLUE YELLOW PURPLE ORANGE CYAN GRAY BROWN PINK GOLD MAGENTA BACKGROUND LIGHT_BLUE LIGHT_GRAY LIGHT_ORANGE LIGHT_GREEN LIGHT_BROWN LIGHT_PINK LIGHT_PURPLE LIGHT_CYAN LIGHT_YELLOW LIGHT_CORAL DARK_GREEN DARK_BLUE DARK_RED DARK_GOLD DARK_PURPLE DARK_BROWN DARK_CYAN DARK_ORANGE DARK_GRAY DARK_PINK AQUA LAVENDER CORAL TEAL INDIGO VIOLET MAROON OLIVE NAVY LIME FUCHSIA SILVER PRIMARY SECONDARY SUCCESS WARNING ERROR INFO TRANSPARENT
rgb (r: int, g: int, b: int) -> tuple
Create RGB color tuple.
创建 RGB 颜色元组。
Params: r,g,b - 0-255
参数:r,g,b - 0-255
rgba (r: int, g: int, b: int, a: int = 255) -> tuple
Create RGBA color tuple.
创建 RGBA 颜色元组。
hex_to_rgb (hex_str: str) -> tuple
Convert hex string to RGB.
将十六进制字符串转换为 RGB。
rgb_to_hex (r: int, g: int, b: int) -> str
Convert RGB to hex string.
将 RGB 转换为十六进制字符串。
complementary (color, mode='rgb') -> tuple
Return complementary color.
返回互补色。
color_lerp (c1, c2, t) -> tuple
Linear interpolation between colors.
颜色线性插值。
rgb_to_hsv (r, g, b) -> tuple
Convert RGB to HSV.
将 RGB 转换为 HSV。
hsv_to_rgb (h, s, v) -> tuple
Convert HSV to RGB.
将 HSV 转换为 RGB。
blend (c1, c2, mode='normal', alpha=0.5) -> tuple
Blend two colors with various modes.
使用多种模式混合两种颜色。
gradient_at (color_dict, t) -> tuple
Sample gradient at position t.
在位置 t 采样渐变色。
gradient_range (color_dict, steps=256) -> list
Generate gradient color list.
生成渐变颜色列表。
grayscale (color) -> int
Convert to grayscale.
转换为灰度。
invert (color) -> tuple
Invert color.
反色。
adjust_brightness (color, factor) -> tuple
Adjust brightness.
调整亮度。
adjust_saturation (color, factor) -> tuple
Adjust saturation.
调整饱和度。
adjust_hue (color, degrees) -> tuple
Adjust hue.
调整色相。
set_alpha (color, alpha) -> tuple
Set alpha channel.
设置 Alpha 通道。
premultiply_alpha (color) -> tuple
Premultiply alpha.
预乘 Alpha。
delta_e (c1, c2) -> float
CIE 1976 color difference.
CIE 1976 色差。
distance (c1, c2) -> float
Euclidean distance in RGB.
RGB 欧几里得距离。
luminance (color) -> float
Relative luminance (WCAG).
相对亮度(WCAG)。
contrast_ratio (c1, c2) -> float
WCAG contrast ratio.
WCAG 对比度比率。
is_dark (color, threshold=0.5) -> bool
Check if color is dark.
检查颜色是否为暗色。
is_light (color, threshold=0.5) -> bool
Check if color is light.
检查颜色是否为亮色。
mix (c1, c2, amount=0.5) -> tuple
Alias for color_lerp.
color_lerp 的别名。
rgb_to_cymb (r, g, b) -> tuple
RGB to CYMB.
RGB 转 CYMB。
cymb_to_rgb (c, y, m, k) -> tuple
CYMB to RGB.
CYMB 转 RGB。
random_color (rng=None) -> tuple
Generate random RGB color.
生成随机 RGB 颜色。

scrypt

gaskill/gaskill/scrypt.py
Cryptography: RSA key generation, encryption/decryption, simple symmetric cipher, secret sharing.
加密:RSA 密钥生成、加密/解密、简单对称加密、秘密共享。
rsa_generate_keys (bits: int = 512) -> dict
Generate RSA key pair.
生成 RSA 密钥对。
rsa_encrypt (message: str, public_key: dict) -> int
RSA encryption.
RSA 加密。
rsa_decrypt (cipher: int, private_key: dict) -> str
RSA decryption.
RSA 解密。
simple_encrypt (value: str, key: str = None, second: list[int] | None = None) -> tuple
Custom symmetric encryption. Returns (cipher, key, IV) if key not provided.
自定义对称加密。若未提供 key,返回 (密文, key, IV)。
simple_decrypt (cipher: int, key: str, IV: str, second: list[int] | None = None) -> str
Decrypt from simple_encrypt.
解密 simple_encrypt 的结果。
share_secret (plaintext: str, keys: list, threshold: int) -> dict
Shamir-style secret sharing.
Shamir 风格秘密共享。
recover_secret (shares_dict: dict, threshold: int) -> str
Recover secret from shares.
从份额恢复秘密。
gaussian_elimination (A, b) -> list
Solve linear system with fractions.
使用分数解线性方程组。

scurve

gaskill/gaskill/scurve.py
Curve evaluation: Bezier (quadratic, cubic, arbitrary degree), B-spline, NURBS.
曲线求值:贝塞尔(二次、三次、任意阶)、B样条、NURBS。
quadratic_bezier (p0, p1, p2, t)
Quadratic Bezier curve.
二次贝塞尔曲线。
cubic_bezier (p0, p1, p2, p3, t)
Cubic Bezier curve.
三次贝塞尔曲线。
bezier (points, t)
De Casteljau evaluation for arbitrary degree.
德卡斯特里奥算法求任意阶贝塞尔曲线。
bezier_derivative (points, t, order=1)
Derivative of Bezier curve.
贝塞尔曲线的导数。
b_spline (control_points, knots, degree, t)
B-spline evaluation using Cox-de Boor.
使用 Cox-de Boor 求 B样条。
uniform_knots (n, degree) -> list
Generate uniform knot vector.
生成均匀节点向量。
clamped_knots (n, degree) -> list
Generate clamped knot vector.
生成钳制节点向量。
b_spline_curve (control_points, degree=3, steps=100) -> list
Generate points on a B-spline curve.
生成 B样条曲线上的点序列。
nurbs (control_points, weights, knots, degree, t)
NURBS curve evaluation.
NURBS 曲线求值。
bezier_path (points, steps=100) -> list
Generate points on a Bezier curve.
生成贝塞尔曲线上的点序列。
bezier_length (points, steps=100) -> float
Approximate Bezier curve length.
估算贝塞尔曲线长度。
curve_length (points_func, steps=100) -> float
Generic curve length calculation.
通用曲线长度计算。
de_casteljau_subdivide (points, t) -> tuple
Subdivide Bezier curve at t.
在 t 处细分贝塞尔曲线。

seasing

gaskill/gaskill/seasing.py
Easing functions for animation: linear, quad, cubic, exponential, circular, elastic, bounce, back, sine.
动画缓动函数:线性、二次、三次、指数、圆形、弹性、弹跳、回退、正弦。
EASING dict mapping names to functions
linear (t) -> float
Linear easing.
线性缓动。
quad_in (t)
Quadratic ease-in.
二次缓入。
quad_out (t)
Quadratic ease-out.
二次缓出。
quad_in_out (t)
Quadratic ease-in-out.
二次缓入缓出。
cubic_in (t)
cubic_out (t)
cubic_in_out (t)
back_in (t)
back_out (t)
bounce_out (t)
bounce_in (t)
bounce_in_out (t)
expo_in (t)
expo_out (t)
expo_in_out (t)
circ_in (t)
circ_out (t)
circ_in_out (t)
elastic_out (t, amplitude=1, period=0.3)
elastic_in (t, amplitude=1, period=0.3)
sine_in (t)
sine_out (t)
sine_in_out (t)
tween (start, end, duration, elapsed, easing=linear)
Compute tween value.
计算补间值。
ease (t, type='linear')
Apply easing by name.
按名称应用缓动。

Tween

class Tween(start, end, duration, easing=linear)
Simple tween animation class.
简单的补间动画类。
update (dt)
Update tween and return current value.
更新补间并返回当前值。
reset ()
Reset to start state.
重置到初始状态。

sevent

gaskill/gaskill/sevent.py
Event system with persistent, once, times, conditional, and delayed listeners.
事件系统,支持持久、一次性、计数、条件和延迟监听器。
event global EventSystem instance

EventSystem

class EventSystem(dt=0.016)
on (event_name, handler) -> int
Register persistent listener.
注册持久监听器。
once (event_name, handler) -> int
Register one-time listener.
注册一次性监听器。
times (count, event_name, handler) -> int
Register listener that fires count times.
注册触发 count 次的监听器。
when (event_name, condition, handler) -> int
Register conditional listener.
注册条件监听器。
wheel_once (event_name, condition, handler) -> int
Conditional listener that fires once.
条件监听器,触发一次。
delay (delay_time, event_name, handler) -> int
Register delayed event.
注册延迟事件。
emit (event_name, *args, **kwargs)
Emit an event.
触发事件。
update (dt=None)
Process delayed events.
处理延迟事件。
remove (event_name, listener_id) -> bool
Remove listener by ID.
按 ID 移除监听器。
redo (event_name, listener_id) -> bool
Reactivate a listener.
重新激活监听器。
clear (event_name=None)
Clear all listeners.
清除所有监听器。

sformat

gaskill/gaskill/sformat.py
String formatting: UUID, superscript, visual length, table, ordinal, polynomial, number-to-words, encode/decode, time, file size.
字符串格式化:UUID、上标、视觉宽度、表格、序数、多项式、数字转英文、编码/解码、时间、文件大小。
uuid4 (obj) -> str
Generate UUID from any object.
从任意对象生成 UUID。
superscript (n) -> str
Convert number to superscript.
将数字转为上标。
visual_len (t) -> int
Visual width: CJK=2, ASCII=1.
视觉宽度:中文=2,英文=1。
center (s, width) -> str
Visually center a string.
按视觉宽度居中对齐。
table (data, border_style="unicode", shows=...) -> str
Render a pretty table.
渲染精美表格。
ordinal (number) -> str
Convert to ordinal string (1st, 2nd, etc.).
转为序数字符串(1st、2nd 等)。
to_poly (expr, use_star=False) -> str
Convert expression to polynomial.
将表达式转为多项式字符串。
number_to_english (n) -> str
Convert number to English words.
数字转英文单词。
english_to_number (s) -> int
Convert English words to number.
英文单词转数字。
insert (base_str, place, insert_str) -> str
Insert substring at position.
在指定位置插入子串。
encode (string) -> str
Encode string to numeric sequence.
将字符串编码为数字序列。
decode (encoded) -> str | tuple
Decode numeric sequence.
解码数字序列。
time_format (seconds, mode='auto') -> str
Format time duration.
格式化时间长度。
file_size (size_bytes, mode='auto', decimal=False) -> str
Format file size.
格式化文件大小。

sfrac

gaskill/gaskill/sfrac.py
Exact rational number arithmetic (Fraction class).
精确有理数运算(分数类)。

Frac

class Frac(numerator, denominator=None)
Immutable fraction with automatic reduction.
不可变分数,自动约分。
as_percent (precision=0) -> str
Return as percentage.
返回百分比字符串。
__pow__ (other)
Exponentiation with rational roots.
含有理根的幂运算。
__format__ (spec)
Supports %, l (LaTeX), m (mixed), f, e.
支持 %、l(LaTeX)、m(带分数)、f、e 格式。
Attributes / 属性: n - numerator / 分子, d - denominator / 分母

sfsm

gaskill/gaskill/sfsm.py
Finite State Machine with state classes and transition tables.
有限状态机,含状态类和转换表。

State

class State(name)
enter (old_state)
Called when entering state.
进入状态时调用。
exit (new_state)
Called when exiting state.
离开状态时调用。
update (dt)
Called every frame.
每帧调用。
handle_event (event) -> str | None
Handle event, return next state.
处理事件,返回下一状态。

StateMachine

class StateMachine(initial_state=None)
add_state (state)
remove_state (state_name)
set_state (state_name) -> bool
update (dt)
handle_event (event) -> bool
transition_to (state_name) -> bool
revert_to_previous () -> bool
lock ()
unlock ()
clear ()
current_state (property)
previous_state (property)

FunctionState

class FunctionState(name, on_enter=None, on_exit=None, on_update=None, on_event=None)
State defined by callbacks.
由回调函数定义的状态。

StateTransition

class StateTransition()
add_transition (from_state, to_state, condition=None)
get_transition (from_state, context=None) -> str | None
clear ()

sgeometry

gaskill/gaskill/sgeometry.py
2D geometry: Polygon, Rect, Circle, Line2, with SAT collision detection.
2D 几何:多边形、矩形、圆、线段,含 SAT 碰撞检测。

Polygon

class Polygon(points)
Arbitrary polygon with triangulation, convex hull, AABB, point-in-polygon.
任意多边形,含三角剖分、凸包、AABB、点在多边形内检测。
get_rects (step=10) -> list
Convert to AABB rectangles.
转换为 AABB 矩形列表。
contains_point (point) -> bool
Ray casting point-in-polygon.
射线法检测点在多边形内。
contains_point_accurate (point) -> bool
Includes boundary check.
包含边界检测。
get_aabb () -> tuple
Axis-aligned bounding box.
轴对齐包围盒。
convex_hull () -> Polygon
Monotone chain convex hull.
单调链凸包。
triangulate () -> list
Ear clipping triangulation.
耳剪裁三角剖分。
collide_rect (rect) -> bool
collide_polygon (other) -> bool
SAT collision detection.
SAT 碰撞检测。
move (dx, dy) -> Polygon
rotate (angle, center=None) -> Polygon
scale (factor, center=None) -> Polygon
edges (property)
normals (property)

Rect

class Rect(x=0, y=0, w=0, h=0, angle=0)
Rectangle with rotation support.
矩形,支持旋转。
get_rects (step=10) -> list
collide_point (x, y=None) -> bool
collide_rect (other) -> bool
collide_circle (circle) -> bool
inflate (dw, dh) -> Rect
expand (*args) -> Rect
move (dx, dy) -> Rect
union (other) -> Rect
left, right, top, bottom, center, area (properties)

Circle

class Circle(center, radius)
collide_point (x, y=None) -> bool
collide_circle (other) -> bool
collide_rect (rect) -> bool
get_rects (step=10) -> list
area (property)

Line2

class Line2(p1, p2)
length () -> float
closest_point (p) -> vec2
collide_point (x, y=None, tolerance=0.1) -> bool
intersect_line (other) -> vec2 | None
raycast_rect (ray_origin, ray_dir, rect) -> tuple
Ray vs rectangle intersection.
射线与矩形相交检测。
reflect (vector, normal) -> vec2
Reflect vector off normal.
向量反射。
rect (x=0, y=0, w=0, h=0, angle=0) -> Rect
circle (center, radius) -> Circle
line (p1, p2) -> Line2

sgeometry3d

gaskill/gaskill/sgeometry3d.py
3D geometry: AABB, Ray, Sphere, Plane.
3D 几何:AABB、射线、球体、平面。

AABB

class AABB(min_point=None, max_point=None)
from_center_size (center, size) -> AABB (classmethod)
from_points (points) -> AABB (classmethod)
expand (point)
inflate (amount)
contains_point (point) -> bool
intersects_aabb (other) -> bool
intersects_sphere (center, radius) -> bool
surface_area () -> float
volume () -> float
merge (other) -> AABB
center, size, extents (properties)

Ray

class Ray(origin=None, direction=None)
point_at (t) -> vec3
intersect_sphere (center, radius) -> tuple
intersect_plane (point, normal) -> tuple
intersect_triangle (v0, v1, v2) -> tuple
Moller-Trumbore.
intersect_aabb (aabb) -> tuple
Slab method.
closest_point_to (point) -> vec3
distance_to_point (point) -> float

Sphere

class Sphere(center=None, radius=1.0)
contains_point (point) -> bool
intersects_sphere (other) -> bool
intersects_aabb (aabb) -> bool
surface_area () -> float
volume () -> float

Plane

class Plane(normal=None, point=None, d=None)
from_three_points (p1, p2, p3) -> Plane (classmethod)
distance_to_point (point) -> float
project_point (point) -> vec3
is_on_plane (point, tolerance=EPSILON) -> bool
project_3d_to_2d (point, camera_pos, camera_angle, fov=60, width=800, height=600)
Project 3D point to 2D screen.
将 3D 点投影到 2D 屏幕。

shashlib

gaskill/gaskill/shashlib.py
Pure Python SHA-256 and DJB2 hash.
纯 Python SHA-256 和 DJB2 哈希。
H0 H1 H2 H3 H4 H5 H6 H7 K 64 constants
sha256 (message: bytes) -> str
Compute SHA-256 hash, return hex digest.
计算 SHA-256 哈希,返回十六进制摘要。
DJB2 (s: str, capacity: int = 0xffffffff) -> int
DJB2 hash function.
DJB2 哈希函数。

sinterp

gaskill/gaskill/sinterp.py
Interpolation: lerp, bilinear, trilinear, slerp, smoothstep, hermite, Catmull-Rom, damping, spring.
插值:线性、双线性、三线性、球面线性、平滑步进、Hermite、Catmull-Rom、阻尼、弹簧。
lerp (a, b, t)
lerp_unclamped (a, b, t)
bilerp (v00, v10, v01, v11, x, y)
trilerp (v000, ..., x, y, z)
slerp (v1, v2, t)
Spherical lerp.
球面线性插值。
smoothstep (edge0, edge1, x)
smootherstep (edge0, edge1, x)
coserp (a, b, t)
cubic_bezier (p0, p1, p2, p3, t)
cubic_bezier_derivative (p0, p1, p2, p3, t)
catmull_rom (p0, p1, p2, p3, t)
hermite (p0, t0, p1, t1, s)
inverse_lerp (a, b, value) -> float
remap (value, in_min, in_max, out_min, out_max)
pingpong (value, length) -> float
damp (current, target, lambda_val, dt)
Exponential damping.
指数阻尼。
spring (current, target, velocity, frequency, damping, dt) -> tuple
Spring interpolation.
弹簧插值。

smath

gaskill/gaskill/smath.py
Core math: constants, trig, complex, log, gamma, primality, number theory.
核心数学:常量、三角函数、复数、对数、Gamma、素数、数论。
pi e tau phi EPSILON INF

Complex

class Complex(real, imag=None)
Complex number with polar coordinates.
复数,含极坐标表示。
conjugate () -> Complex
copy () -> Complex
real, imag, r, theta (properties)
gcd (a, b) -> int
lcm (a, b) -> int
factorial (n) -> int
comb (n, k) -> int
perm (n, k) -> int
gamma (z)
Gamma function.
Gamma 函数。
log_gamma (z) -> float
digamma (z) -> float
beta (a, b) -> float
sin (x, fast=False)
cos (x, fast=False)
tan (x)
cot (x)
sec (x)
csc (x)
asin (x)
acos (x)
atan (x)
atan2 (y, x)
sinh (x)
cosh (x)
tanh (x)
coth (x)
acosh (x)
asinh (x)
atanh (x)
exp (z)
log (z, base=None)
ln (z)
log10 (z)
log2 (z)
sqrt (x)
cbrt (x)
root (x, n=2)
hypot (*args) -> float
floor (x) -> int
ceil (x) -> int
trunc (x) -> int
sign (x) -> int
rad (x) -> float
deg (x) -> float
wrap (x, a, b) -> float
clamp (x, min_val, max_val)
is_prime (n) -> bool
is_prime_fast (n) -> bool
Miller-Rabin.
prime_factors (n) -> dict
fibonacci (n) -> int
product (arr)
normalize_angle (angle) -> float
distance (p1, p2) -> float
nearest (value, candidates)
angle_between (v1, v2) -> float
egcd (a, m) -> int
Modular inverse.
模逆元。

smatrix

gaskill/gaskill/smatrix.py
Matrix class with linear algebra operations.
矩阵类,含线性代数运算。

Matrix

class Matrix(data)
transpose () -> Matrix
T (property)
trace () -> float
det () -> float
inverse () -> Matrix
rank () -> int
lu_decomposition () -> tuple
submatrix (row_start, row_end, col_start, col_end) -> Matrix
minor (i, j) -> float
cofactor (i, j) -> float
adjugate () -> Matrix
frobenius_norm () -> float
infinity_norm () -> float
one_norm () -> float
is_symmetric () -> bool
is_identity () -> bool
is_diagonal () -> bool
diagonal () -> list
to_vector () -> list
matrix (data) -> Matrix
rotation_matrix_2d (theta) -> Matrix
rotation_matrix_x (theta) -> Matrix
rotation_matrix_y (theta) -> Matrix
rotation_matrix_z (theta) -> Matrix
scaling_matrix_2d (sx, sy=None) -> Matrix
scaling_matrix_3d (sx, sy=None, sz=None) -> Matrix
translation_matrix_2d (tx, ty) -> Matrix
translation_matrix_3d (tx, ty, tz) -> Matrix
solve_linear (A, b) -> list
eigenvalues_2x2 (matrix) -> list
kronecker (A, B) -> Matrix
outer_product (v1, v2) -> Matrix
matrix_from_func (func, rows, cols=None, start=(0,0)) -> Matrix

snoise

gaskill/gaskill/snoise.py
Procedural noise: Perlin, Simplex, and point-based noise.
程序化噪声:Perlin、Simplex 和基于点的噪声。

PerlinNoise

class PerlinNoise(seed=None, octaves=4, persistence=0.5, lacunarity=2.0)
noise2d (x, y) -> float
fbm2d (x, y) -> float
terrain_height (x, y) -> float

SimplexNoise

class SimplexNoise(seed=None, octaves=4, persistence=0.5, lacunarity=2.0)
Correct Simplex noise, no square artifacts.
正确的 Simplex 噪声,无方块痕迹。
noise2d (x, y) -> float
fbm2d (x, y) -> float

Snoise

class Snoise(falloff=1.0)
Point-based noise field (inverse distance weighting).
基于点的噪声场(反距离加权)。
add_point (x, y, value) -> self
add_points (*points) -> self
clear () -> self
set_falloff (falloff) -> self
__call__ (x, y, use_cache=True) -> float
sample_rect (x1, y1, x2, y2, step=1.0) -> list
heatmap (x1, y1, x2, y2, step=1.0) -> list
snoise_from_points (points, falloff=1.0) -> Snoise

solver

gaskill/gaskill/solver.py
Equation solvers: linear, quadratic, cubic, and numerical polynomial (Durand-Kerner).
方程求解器:一次、二次、三次和数值多项式(Durand-Kerner)。
solve_linear (a, b) -> list | str
Returns 'infinite' for infinite solutions.
无数解时返回 'infinite'。
solve_quadratic (a, b, c) -> list
Supports complex roots.
支持复数根。
solve_cubic (a, b, c, d) -> list
solve_polynomial (coefficients) -> list
Up to degree 3.
最高三次。
solve_polynomial_numerical (coefficients, max_iter=1000, tol=1e-10) -> list
roots (coefficients) -> list
Alias for numerical solver.
数值求解器别名。
poly (val, coefficients)
Evaluate polynomial.
计算多项式值。

spathfinder

gaskill/gaskill/spathfinder.py
Pathfinding: A*, Dijkstra, BFS, bidirectional BFS, flow field, maze generation.
寻路:A*、Dijkstra、BFS、双向BFS、流场、迷宫生成。
astar (grid, start, end, heuristic='manhattan', allow_diagonal=False) -> list | None
astar_weighted (grid, start, end, weight=1.0, ...) -> list | None
dijkstra (grid, start, end, weights=None, allow_diagonal=False) -> list | None
bidirectional_bfs (grid, start, end) -> list | None
bfs (grid, start, end) -> list | None
dfs_maker (width, height, start=(1,1), seed=None) -> list
astar_cost (cost_grid, start, end, ...) -> list | None
dijkstra_cost (cost_grid, start, end, ...) -> list | None
get_path_cost (cost_grid, path, allow_diagonal=False) -> float
create_cost_grid (grid, default_cost=1.0, wall_cost=-1.0, custom_costs=None) -> list
compute_flow_field (grid, goals, allow_diagonal=True, cost_map=None) -> tuple
get_flow_direction (flow_field, x, y) -> tuple
move_toward_flow (flow_field, x, y, speed) -> tuple
visualize_flow_field (flow_field, symbols=None) -> str
sample_flow_path (flow_field, start_x, start_y, steps=100) -> list

spickle

gaskill/gaskill/spickle.py
Binary serialization (pickle-like) without dependencies.
二进制序列化(类 pickle),无依赖。
pack_float (num: float) -> str
unpack_float (byte_data: bytes) -> float
pack_int (n: int, bits=None) -> str
pack_str (n: str) -> str
bits_to_bytes (bits: str) -> bytes
bytes_to_bits (data: bytes) -> str
pack (obj) -> bytes
unpack (data: bytes, pos: int = 0) -> tuple
dump (obj, filename: str)
load (filename: str) -> object

spool

gaskill/gaskill/spool.py
Object pool, auto-release pool, and stack allocator.
对象池、自动释放池和栈分配器。

ObjectPool

class ObjectPool(factory=None, reset_func=None, max_size=100)
acquire (*args, **kwargs) -> object
release (obj)
clear ()
available_count (property)
in_use_count (property)
total_count (property)

PooledObject

class PooledObject()
recycle ()
on_acquire ()
on_release ()
is_active (property)

AutoReleasePool

class AutoReleasePool()
add (obj, release_method='recycle')
release_all ()
count (property)

StackAllocator

class StackAllocator(initial_capacity=100)
push (obj)
pop ()
pop_multiple (count) -> list
clear ()
size (property)
capacity (property)

squaternion

gaskill/gaskill/squaternion.py
Quaternion math for 3D rotations.
四元数数学,用于 3D 旋转。
IDENTITY ZERO

Quaternion

class Quaternion(w=1.0, x=0.0, y=0.0, z=0.0)
copy () -> Quaternion
conjugate () -> Quaternion
norm () -> float
norm_squared () -> float
normalize () -> Quaternion
inverse () -> Quaternion
dot (other) -> float
to_axis_angle () -> tuple
to_matrix () -> Matrix
rotate_vector (v) -> vec3
from_axis_angle (axis, angle) -> Quaternion (staticmethod)
from_euler (roll, pitch, yaw) -> Quaternion (staticmethod)
from_two_vectors (v1, v2) -> Quaternion (staticmethod)
slerp (q1, q2, t) -> Quaternion
nlerp (q1, q2, t) -> Quaternion
squad (q0, q1, q2, q3, t) -> Quaternion
angular_velocity (q1, q2, dt) -> vec3
integrate_angular_velocity (q, omega, dt) -> Quaternion
look_at (eye, target, up=None) -> Quaternion
random_quaternion (rng=None) -> Quaternion

srandom

gaskill/gaskill/srandom.py
Random number generator with dice rolling, Gaussian, UUID, sampling, shuffling.
随机数生成器,含骰子、高斯分布、UUID、抽样、洗牌。

Random

class Random(seed=None)
seed (seed)
next (a=0, b=9) -> int
roll (expr: str) -> int
randint (a, b) -> int
random () -> float
random_float (start, end) -> float
choice (candidates)
shuffle (items)
shuffle_copy (items) -> list
sample (items, k) -> list
choices (arr, weight=None)
gauss (mu=0.0, sigma=1.0) -> float
random_from_func (func, x_min, x_max, step=0.01, y_max=None) -> float
uuid () -> str
uniform (a, b) -> float
random_ascii (length=16, charset='ascii') -> str
random (rng=None) -> float
randint (a, b, rng=None) -> int
choice (seq, rng=None)
shuffle (seq, rng=None)
sample (seq, k, rng=None)
random_ascii (length=16, charset='ascii', rng=None) -> str

ssaver

gaskill/gaskill/ssaver.py
Save/Load system (SGT format) with hash verification.
存档/读档系统(SGT 格式),含哈希校验。

SGTsaver

class SGTsaver()
set_value (**kwargs) -> self
add (key, value) -> self
save (filename, use_hash=True) -> bool
load (filename, require_hash=True) -> dict
get (key, default=None)
__getitem__ (key)
__setitem__ (key, value) -> self

sstat

gaskill/gaskill/sstat.py
Statistics: mean, median, mode, variance, correlation, regression, distributions, tests.
统计:均值、中位数、众数、方差、相关性、回归、分布、检验。
erf (x) -> float
mean (data) -> float
geometric_mean (data) -> float
harmonic_mean (data) -> float
median (data) -> float
mode (data) -> list
quantile (data, p) -> float
quartiles (data) -> tuple
iqr (data) -> float
variance (data, ddof=0) -> float
stdev (data, ddof=0) -> float
mad (data) -> float
range_stat (data) -> float
cv (data, ddof=0) -> float
skewness (data, ddof=0) -> float
kurtosis (data, ddof=0) -> float
covariance (x, y) -> float
correlation (x, y) -> float
spearman (x, y) -> float
linear_regression (x, y) -> tuple
normal_pdf (x, mu=0, sigma=1) -> float
normal_cdf (x, mu=0, sigma=1) -> float
binomial_pmf (k, n, p) -> float
poisson_pmf (k, lam) -> float
z_score (x, mu, sigma) -> float
t_test (data, mu0) -> tuple
chi_square (observed, expected) -> float
f_test (a, b) -> float
normalize (data, new_min=0, new_max=1) -> list
standardize (data) -> list
rolling_mean (data, window) -> list
ewma (data, alpha) -> list
summary (data) -> dict
probability_distribution (data) -> dict

svector

gaskill/gaskill/svector.py
Vector classes: vec2, vec3, vec4 with arithmetic, dot, cross, normalization, rotation.
向量类:vec2、vec3、vec4,含算术、点积、叉积、归一化、旋转。

vec2

class vec2(x=0.0, y=0.0)
copy () -> vec2
dot (other) -> float
cross (other) -> float
length () -> float
length_squared () -> float
normalize () -> vec2
distance (other) -> float
lerp (other, t) -> vec2
rotate_around (center, angle) -> vec2
reflect (normal) -> vec2
project (onto) -> vec2
reject (onto) -> vec2
rotate (angle) -> vec2
angle () -> float
angle_to (other) -> float
perpendicular () -> vec2
zero, one, up, down, left, right (staticmethods)
from_angle (angle) -> vec2 (staticmethod)

vec3

class vec3(x=0.0, y=0.0, z=0.0)
copy, dot, cross, length, normalize, distance, lerp
rotate_around (center, axis, angle) -> vec3
rotate_x, rotate_y, rotate_z (angle) -> vec3
reflect, project, reject
to_tuple, to_list
zero, one, up, down, left, right, forward, back (staticmethods)

vec4

class vec4(x=0.0, y=0.0, z=0.0, w=0.0)
copy, dot, length, normalize, distance, lerp
to_vec3 (w_divide=True) -> vec3
to_rgba, to_rgb
zero, one, unit_x, unit_y, unit_z, unit_w (staticmethods)
from_vec3, from_rgba, from_tuple, from_list (staticmethods)
v2 (x=0, y=0) -> vec2
v3 (x=0, y=0, z=0) -> vec3
v4 (x=0, y=0, z=0, w=0) -> vec4
vlerp, distance, dot, cross, normalize, angle_between

type

gaskill/gaskill/type.py
Type utilities: DefaultDict, Iterable, Callable, Number ABCs.
类型工具:DefaultDict、Iterable、Callable、Number 抽象基类。

DefaultDict

class DefaultDict(default_factory=None, **kwargs)
update (other)
get (key, default=None)
pop (key, default=None)
keys, values, items
copy () -> DefaultDict
clear ()

Iterable

class Iterable(ABC)
Abstract base class for iterables.
可迭代对象的抽象基类。

Callable

class Callable(ABC)
Abstract base class for callables.
可调用对象的抽象基类。

Number

class Number(ABC)
Abstract base class for numbers.
数值类型的抽象基类。

plus

gaskill/plus/__init__.py
Aggregator for plus modules: radical, poly, zip, re, bmp, ecc, decimal, database, tester, fft, csv.
plus 模块聚合器:radical、poly、zip、re、bmp、ecc、decimal、database、tester、fft、csv。

Imported Symbols / 导入的符号

radical Radical class, real_sqrt, real_rootRadical 类、real_sqrt、real_root
poly Poly class, factors_to_strPoly 类、factors_to_str
zip compress, decompress
re Regex classRegex 类
bmp BMPImage, BMPError
ecc Point, ECDSA functionsPoint、ECDSA 函数
decimal Decimal, prec, dec_* functionsDecimal、prec、dec_* 函数
database DiskKV
tester TestCase, TestRunner, test, skip
fft fft, ifft, fftshift, etc.
csv load_csv, save_csv, etc.

bmp

gaskill/plus/bmp.py
Pure Python BMP image reader/writer. Supports 1, 4, 8, 16, 24, 32 bit.
纯 Python BMP 图像读写器。支持 1、4、8、16、24、32 位。

BMPError

class BMPError(Exception)

BMPImage

class BMPImage(width=0, height=0)
set_pixel (x, y, color)
get_pixel (x, y) -> tuple
load (filename) -> BMPImage (classmethod)
load_from_bytes (data) -> BMPImage (classmethod)
save (filename)
create_checkerboard (width, height, size=10) -> BMPImage (classmethod)
create_gradient (width, height) -> BMPImage (classmethod)
to_rgb ()

csv

gaskill/plus/csv.py
CSV reading/writing with quoting and escaping.
CSV 读写,支持引号和转义。
load_csv (fileobj, delimiter=',', quotechar='"', has_header=True)
save_csv (fileobj, data, header=None, delimiter=',', quotechar='"')
load_csv_file (filepath, ...)
save_csv_file (filepath, ...)
load_csv_str (content, ...)
save_csv_str (data, ...) -> str
dict_to_csv (data, fields=None, ...) -> tuple
csv_to_dict (header, rows) -> list

database

gaskill/plus/database.py
Disk-based key-value store with hash indexing.
基于磁盘的键值存储,含哈希索引。

DiskKV

class DiskKV(filepath, initial_capacity=131072)
set (key, value)
get (key, default=None)
flush ()
close ()

decimal

gaskill/plus/decimal.py
Arbitrary precision decimal arithmetic. Global prec (default 50).
任意精度十进制运算。全局 prec(默认 50)。
prec Global precision setting

Decimal

class Decimal(value, fr_len=None)
Arbitrary precision decimal number.
任意精度十进制数。
Supports +, -, *, /, //, %, **, comparison, round, int, float
dec_exp (value) -> Decimal
dec_ln (value) -> Decimal
dec_pi () -> Decimal
dec_e () -> Decimal
dec_ln2 () -> Decimal
dec_sin (x) -> Decimal
dec_cos (x) -> Decimal
dec_atan (x) -> Decimal
asin (x) -> Decimal

ecc

gaskill/plus/ecc.py
ECDSA on secp256k1 with user-provided ephemeral key k.
secp256k1 上的 ECDSA,用户提供临时密钥 k。
p a b n G

Point

class Point(x, y, a, b, p)
is_infinity () -> bool
is_on_curve () -> bool
__add__ (other) -> Point
__mul__ (k) -> Point
sha256_int (message) -> int
is_valid_private_key (k) -> bool
is_valid_k (k) -> bool
ecdsa_sign_with_k (private_key, message, k) -> tuple
ecdsa_verify (public_key, message, signature) -> bool

fft

gaskill/plus/fft.py
Fast Fourier Transform with arbitrary length (zero-padded to power of 2).
快速傅里叶变换,任意长度(补零到 2 的幂次)。
fft (x) -> tuple
ifft (X, original_length=None) -> list
fftfreq (N, d=1.0) -> list
fftshift (x) -> list
ifftshift (x) -> list
magnitude_spectrum (x, shift=False) -> list
power_spectrum (x, shift=False) -> list
phase_spectrum (x, shift=False) -> list

poly

gaskill/plus/poly.py
Polynomial algebra: creation, arithmetic, factoring, derivative, evaluation.
多项式代数:创建、运算、因式分解、求导、求值。

Poly

class Poly(terms=None)
from_string (poly_str) -> Poly (classmethod)
degree (var=None) -> int
extract_gcf () -> tuple
evaluate (values) -> float | int
derivative (var='x') -> Poly
factor () -> list
factors_to_str (factors) -> str

radical

gaskill/plus/radical.py
Symbolic radicals with arithmetic and simplification.
符号根式,含运算和化简。

Radical

class Radical(index, radicand, coeff=1)
Represents coeff * (radicand)^(1/index).
表示 coeff * (根号内)^(1/index)。
conjugate () -> Radical | None
approx () -> float
Supports +, -, *, /, **, negation
real_sqrt (n) -> Radical
real_root (n, x) -> Radical

re

gaskill/plus/re.py
Pure Python regex engine. Supports ., *, +, ?, |, ^, $, character classes, escapes, {min,max}.
纯 Python 正则引擎。支持 ., *, +, ?, |, ^, $、字符类、转义、{min,max}。

Regex

class Regex(pattern: str)
match (text: str) -> bool

sql

gaskill/plus/sql.py
Read-heavy matrix database with ordered indexes and lazy SearchResult.
读多写少的矩阵数据库,含有序索引和惰性 SearchResult。

ReadingSQL

class ReadingSQL(data=None)
load (data)
get (row, col)
set (row, col, value)
insert_row (row_data)
insert_col (col_data)
delete_row (row_idx)
delete_col (col_idx)
search (value_or_condition) -> SearchResult
search_range (low, high) -> SearchResult
search_less (value) -> SearchResult
search_greater (value) -> SearchResult
search_rect (row_start, row_end, col_start, col_end) -> SearchResult
sum (col=None) -> float
avg (col=None) -> float
max (col=None) -> float
min (col=None) -> float
count (col=None) -> int
head (n=5) -> list
tail (n=5) -> list
to_list () -> list
to_matrix () -> Matrix

SearchResult

class SearchResult(...)
list () -> list
first (n=1) -> list
last (n=1) -> list
count () -> int
__add__ (other) -> SearchResult
readingsql (data=None) -> ReadingSQL

sui

gaskill/plus/sui.py
Simple UI components: Label, Button, Bar, Entry.
简单 UI 组件:标签、按钮、进度条、输入框。
draw (cmd_type) -> decorator
render_all (components) -> list

UI

class UI(x, y, width, height)
render () (abstract)
handle_event (event)
config (**kwargs)
destroy ()
is_visible () -> bool

Label

class Label(x, y, width, height, text="", **kwargs)
render () -> list
config (**kwargs)
enter (mouse_x, mouse_y) -> bool

Button

class Button(x, y, width, height, text="", **kwargs)
render () -> list
handle_event (mouse_pos, keys) -> bool
press ()
release () -> bool

Bar

class Bar(x, y, width, height, value=1.0, **kwargs)
render () -> list
config (**kwargs)
set_hp (current, max_hp)

Entry

class Entry(x, y, width, height, text="", **kwargs)
render () -> list
handle_event (mouse_pos, keys, dt) -> bool
config (**kwargs)
enter (mouse_x, mouse_y) -> bool

tester

gaskill/plus/tester.py
Unit testing framework with @test, @skip, TestCase, TestRunner.
单元测试框架,含 @test、@skip、TestCase、TestRunner。
test (func) -> callable
skip (reason="跳过") -> decorator

TestCase

class TestCase()
Base test case with setup/teardown and assertions.
测试用例基类,含 setup/teardown 和断言。
setup ()
teardown ()
setup_class () (classmethod)
teardown_class () (classmethod)
assert_equal (a, b)
assert_not_equal (a, b)
assert_almost_equal (a, b, places=7)
assert_not_almost_equal (a, b, places=7)
assert_greater (a, b)
assert_greater_equal (a, b)
assert_less (a, b)
assert_less_equal (a, b)
assert_true (x)
assert_false (x)
assert_is (a, b)
assert_is_not (a, b)
assert_is_none (x)
assert_is_not_none (x)
assert_in (a, b)
assert_not_in (a, b)
assert_isinstance (a, b)
assert_not_isinstance (a, b)
assert_issubclass (a, b)
assert_not_issubclass (a, b)
assert_count_equal (a, b)
assert_starts_with (a, b)
assert_not_starts_with (a, b)
assert_ends_with (a, b)
assert_not_ends_with (a, b)
assert_has_attr (a, b)
assert_not_has_attr (a, b)
assert_raises (exc_class, func=None, *args, **kwargs)

TestRunner

class TestRunner()
run_single_test (test_instance, method) -> tuple
run_class (test_class) -> dict
run_all () -> bool

zip

gaskill/plus/zip.py
Pure Python LZ77 + Huffman compression.
纯 Python LZ77 + Huffman 压缩。
compress (data) -> tuple
decompress (data, codes, count) -> bytes
lz77_compress (data, window_size=32768, max_match=258) -> list
build_huffman_tree (freq) -> HuffmanNode
generate_huffman_codes (node, code='', codes={}) -> dict

BitWriter

class BitWriter()
write_bit (bit)
write_bits (bits)
to_bytes () -> bytes

BitReader

class BitReader(data)
read_bit () -> int | None
read_bits (n) -> list

HuffmanNode

class HuffmanNode(freq, char=None, left=None, right=None)