Closed
Conversation
Replace per-element append to 3 separate lists with per-channel list comprehensions. Reduces self-time by ~80% by avoiding 768+ individual append calls per invocation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Inline the vertex computation, eliminating nested helper functions (_apply_rotation, _compute_polygon_vertex, _get_angles). Simplify the rotation formula since start_point is always [radius, 0], reducing from 4 trig calls to 2 per vertex. Cache math functions as locals. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Specialize for the common cases (both tuples, one scalar) to avoid unnecessary tuple wrapping and generator overhead per call. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Precompute normalized coordinate arrays to avoid repeated division in tight loops. Replace slice assignment with list.extend for lower per-iteration overhead. Cache table.extend as local variable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace functools.reduce(operator.add, ...) with sum() in equalize - Replace functools.reduce(lambda a,b: a+b, ...) with sum() in Kernel - Replace per-element loop in solarize with list comprehension - Replace sum loop in autocontrast with sum(h) builtin - Use lut.extend(range(256)) instead of lut.extend(list(range(256))) - Use min/max in autocontrast LUT building for clarity and slight perf - Remove unused functools and operator imports Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Split the inner loop into two paths to avoid checking border is None on every pixel. Replace p not in (value, border) with direct comparisons to avoid tuple creation per pixel. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace nested for loops with generator-based sum() calls inside list comprehensions. Also use j*j instead of j**2 to avoid pow overhead. Cache self.h as local in median. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace 2 ** (8 - bits) with 1 << (8 - bits) for faster bitmask computation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
For the common 3-element (RGB) and 4-element (RGBA) cases, compute the L1 norm directly instead of using sum(generator). Eliminates generator/zip overhead for the hot path in floodfill. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace append loop with list comprehension for collecting used palette colors in _get_optimize. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace extend-in-loop with chain.from_iterable for flattening nested sequences in Color3DLUT constructor. Separate validation from flattening for cleaner code. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes # .
Changes proposed in this pull request: