Arrays pop()?

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
lofer
Posts: 13
Joined: Tue Mar 31, 2020 5:17 am

Arrays pop()?

Post by lofer » Tue Jun 08, 2021 7:20 am

What for arrays are if it is impossible to pop() anything from them in micropython?
I would love to use them instead of lists but how?

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Arrays pop()?

Post by pythoncoder » Wed Jun 09, 2021 4:39 am

You access them by index or by slice notation (a[4:10]). You can also create generators from them:

Code: Select all

a = array.array('I', range(32))
i = (x for x in a if x > 4)
b = array.array('I', i)
Arrays are much less flexible than lists but they are highly efficient as elements are stored in contiguous memory locations. Consequently they are useful for passing data to and from code written using the inline assembler, and are a natural for writing device drivers for chips that provide memory such as Flash or EEPROMs.
Peter Hinch
Index to my micropython libraries.

Post Reply