diff options
| author | Daniel Thompson <daniel@redfelineninja.org.uk> | 2021-01-17 17:44:21 (GMT) |
|---|---|---|
| committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2021-01-17 17:44:21 (GMT) |
| commit | 6b41c8f3db1778826ec8556f8900878a8f32c87a (patch) | |
| tree | 8b65647a30cbf54f7a4bc314b4d4adcabda4701a /wasp/drivers | |
| parent | 5abae5a7f63f6841744ad63e7c8bbbb1d8452b37 (diff) | |
drivers: st7789: Pre-allocate a memoryview
Reduce the cost of slicing the linebuffer by pre-allocating a memoryview.
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Diffstat (limited to 'wasp/drivers')
| -rw-r--r-- | wasp/drivers/st7789.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/wasp/drivers/st7789.py b/wasp/drivers/st7789.py index e689e4e..817c414 100644 --- a/wasp/drivers/st7789.py +++ b/wasp/drivers/st7789.py @@ -44,7 +44,7 @@ class ST7789(object): """ self.width = width self.height = height - self.linebuffer = bytearray(2 * width) + self.linebuffer = memoryview(bytearray(2 * width)) self.init_display() def init_display(self): @@ -167,7 +167,7 @@ class ST7789(object): self.set_window(x, y, w, h) # Populate the line buffer - buf = memoryview(self.linebuffer)[0:2*w] + buf = self.linebuffer[0:2*w] for xi in range(0, 2*w, 2): buf[xi] = bg >> 8 buf[xi+1] = bg & 0xff |
