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?
Arrays pop()?
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Arrays pop()?
You access them by index or by slice notation (a[4:10]). You can also create generators from them:
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.
Code: Select all
a = array.array('I', range(32))
i = (x for x in a if x > 4)
b = array.array('I', i)
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.