From 7bc29398d29f73cf40976dbc21245e5905e84a37 Mon Sep 17 00:00:00 2001 From: Greg Smith Date: Sun, 5 Jun 2022 19:45:20 -0400 Subject: [PATCH] faster generation of zero-arrays --- neopixel.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/neopixel.py b/neopixel.py index 0a89df6..5bb4a1c 100644 --- a/neopixel.py +++ b/neopixel.py @@ -68,7 +68,7 @@ class Neopixel: #] def __init__(self, num_leds, state_machine, pin, mode="RGB", delay=0.0001): - self.pixels = array.array("I", [0 for _ in range(num_leds)]) + self.pixels = array.array("I", [0] * num_leds) self.mode = mode self.W_in_mode = 'W' in mode if self.W_in_mode: @@ -248,4 +248,5 @@ class Neopixel: # Clear the strip def clear(self): - self.pixels = array.array("I", [0 for _ in range(self.num_leds)]) + self.pixels = array.array("I", [0] * self.num_leds) +