Quantcast
Viewing all articles
Browse latest Browse all 6078

MicroPython • Re: Slicing bytearray without copying it, possible?

There's 'MemoryView' or something like that. I have never used it and am not convinced it doesn't copy. And I am not convinced there is what you want from when I last dipped into looking at doing similar.
That did the trick, thanks!
Al that was needed was replacing

Code:

byte_buffer = bytearray(MAX_BUFFER_SIZE)
with

Code:

_byte_buffer = bytearray(MAX_BUFFER_SIZE)byte_buffer = memoryview(_byte_buffer)
Googling for memoryview I came accross an article with many more tips to increase the efficiency of my code: https://docs.micropython.org/en/latest/ ... ython.html. Especially caching object references increased the drawing speed quite a lot more as well!
In this respect MicroPython on an RP2040 isn't the ideal tool for the job.
I know, but since for my work I’m managing a couple of analysts using Python I wanted to finally get to use it myself as well, so when I had a hobby project for with no readily available solution, I decided to build it myself and learn the ins and outs of Python in one go (I’ve used several other programming languages over the years, just never Python, up to recently).

Statistics: Posted by harmlammers — Sat May 04, 2024 9:31 am



Viewing all articles
Browse latest Browse all 6078

Trending Articles