Skip to content

Commit 06b50d0

Browse files
committed
faster reverse
1 parent f6d0a61 commit 06b50d0

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

coloraide/algebra.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2062,7 +2062,7 @@ def transpose(array: ArrayLike | float) -> Array | float:
20622062
we don't have a need for that, nor the desire to figure it out :).
20632063
"""
20642064

2065-
s = tuple(reversed(shape(array)))
2065+
s = shape(array)[::-1]
20662066
if not s:
20672067
return array # type: ignore[return-value]
20682068

docs/src/py/notebook.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -696,21 +696,21 @@ def _color_command_formatter(src="", language="", class_name=None, options=None,
696696
freq = 16
697697
offset = 24
698698

699-
primary = list(reversed(colors[::freq]))
700-
secondary = list(reversed(colors[offset::freq] + [colors[offset // 3]]))
701-
tertiary = list(reversed(colors[::offset // 6]))
699+
primary = colors[::freq][::-1]
700+
secondary = colors[offset::freq] + [colors[offset // 3]][::-1]
701+
tertiary = colors[::offset // 6][::-1]
702702
color_rings = [primary, secondary, tertiary]
703703

704704
extra_rings_start = ''
705705
extra_rings_end = ''
706706
if l > 12:
707707
extra_rings_start = '<div class="tertiary2">'
708708
extra_rings_end += '</div>'
709-
color_rings.append(list(reversed(colors[::offset // 12])))
709+
color_rings.append(colors[::offset // 12][::-1])
710710
if l > 24:
711711
extra_rings_start = '<div class="tertiary3">' + extra_rings_start
712712
extra_rings_end += '</div>'
713-
color_rings.append(list(reversed(colors)))
713+
color_rings.append(colors[::-1])
714714

715715
color_stops = ''
716716
for i, colors in enumerate(color_rings, 1):

tools/slice_diagram.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def plot_slice(
257257

258258
if hue_index == -1:
259259
# Combine the min/max values in one shape
260-
edge_x.extend(reversed(temp))
260+
edge_x.extend(temp[::-1])
261261
# Close shape
262262
edge_x.append(edge_x[0])
263263

@@ -271,7 +271,7 @@ def plot_slice(
271271
edge_y.append((edges[0], p1))
272272
temp.append((edges[1], p1))
273273

274-
edge_y.extend(reversed(temp))
274+
edge_y.extend(temp[::-1])
275275
edge_y.append(edge_y[0])
276276

277277
# Get the intersection of X and Y to get the most accurate border

0 commit comments

Comments
 (0)