Latest / Talk Python To Me / #325: MicroPython + CircuitPython
Transcript
- 0:00When you think about embedded programming, does it bring low-level languages and tools to mind?
- 0:04Maybe embedded C or even assembly language?
- 0:07Thanks to the groundbreaking work by Damian George back in 2014 to create MicroPython,
- 0:12Python is one of the very solid choices for building tiny programmable devices.
- 0:17On this episode, we welcome back Damian George from MicroPython,
- 0:21along with Scott Shawcraft from CircuitPython and Adafruit.
- 0:24We'll talk about how these two frameworks are solving similar problems with slightly different philosophies.
- 0:29More importantly, they are working closely to bring MicroPython and CircuitPython more in sync.
- 0:35This is Talk Python To Me, episode 325, recorded July 8th, 2021.
- 0:55Welcome to Talk Python To Me, a weekly podcast on Python, the language, the libraries, the ecosystem, and the personalities.
- 1:01This is your host, Michael Kennedy.
- 1:03Follow me on Twitter where I'm @mkennedy,
- 1:05and keep up with the show and listen to past episodes at talkpython.fm,
- 1:08and follow the show on Twitter via at Talk Python.
- 1:12This episode is brought to you by Sentry and Linode,
- 1:15and the transcripts are brought to you by Assembly AI.
- 1:18Please check out what they're offering during their segments.
- 1:20It really helps support the show.
- 1:23Scott, Damian, welcome to Talk Python To Me.
- 1:26Damian, welcome back.
- 1:26Scott, great to have you here.
- 1:28Thanks for having me.
- 1:29Hi, yeah.
- 1:29Thanks for having me as well.
- 1:30Really good to have you both here.
- 1:31And normally I ask people how they got into programming.
- 1:34Damian, you've already told your story,
- 1:36and maybe I think we'll mix it up just a little bit.
- 1:38Let's maybe just have you both do a quick introduction about,
- 1:42you know, how you fit into the Python world and what you're up to these days.
- 1:46Damian, you want to go first?
- 1:47Sure.
- 1:47I'm the creator of MicroPython.
- 1:50It's been a long journey in the past nine years or so.
- 1:54Before that, I was a theoretical physicist,
- 1:58and I studied at Melbourne University in Australia and did a PhD in theoretical physics.
- 2:04My PhD was in extra dimensions and kind of string theory related stuff.
- 2:09That's super cool.
- 2:10Yeah, it was.
- 2:11Oh, see, it couldn't be like a, you know, astrophysics type thing.
- 2:15It's got to be something small if you're working on MicroPython, right?
- 2:18Like if that's your deal.
- 2:19Well, the thing with the particle physics is all about the tiny, tiny things.
- 2:23The quarks is sort of as small as we know,
- 2:27but also linking to cosmology, which is the really, really huge thing.
- 2:32And the idea of cosmology is to link the tiny with the large.
- 2:36But yeah, that's all, I guess, very different from microcontrollers and programming and software
- 2:41and hardware and real tangible things.
- 2:44How'd you get from physics to programming side of things?
- 2:47I always liked computers and programming.
- 2:50And I always sort of had that as a side hobby.
- 2:54And I actually also studied computer engineering and mathematics.
- 2:57But physics was the thing I kept, you know, I did sort of professionally,
- 3:01if you could say that.
- 3:03And always had on the side, you know, microcontrollers and my desk and CNC machines
- 3:08and sort of half-built robots.
- 3:11Fantastic.
- 3:11Yeah.
- 3:12So turned that eventually into MicroPython.
- 3:14And when I was doing my PhD, when I was doing a postdoc in Cambridge and yeah,
- 3:19did a Kickstarter with MicroPython.
- 3:20And then that all sort of continued on and continued and grew and grew.
- 3:24And that's how I sort of end up where I am now.
- 3:27Cool.
- 3:28Kickstarter was so neat when it came out in 2015, 2014, whatever time that was.
- 3:33It seemed like it had such possibility.
- 3:35Now I don't hear about it as much anymore.
- 3:37And I know it's still out there, but...
- 3:38Yeah, I think it was a bit earlier than that because we did it in the end of 2013.
- 3:41And it had already been around a few years.
- 3:43Yeah.
- 3:44Yeah.
- 3:44But it was, yeah, such a huge thing back then.
- 3:47So super cool that you launched it on that.
- 3:49Scott, how about you?
- 3:50So I got into programming with PHP was my first language.
- 3:53So I came kind of like from the web side of things.
- 3:55And then when I wanted to do desktop apps, I found Python.
- 3:59And you can still find a source for page, source forge page for a program called Denu,
- 4:05which was like dynamic menu stuff for like managing your menus in Linux.
- 4:09That was my first Python program.
- 4:11That was 2004.
- 4:13So that's before I went to university.
- 4:14And then I got a computer engineering degree and I taught some of the intro TA classes there
- 4:21and did like a Python version of it there.
- 4:22So like Pythons kind of always followed me throughout my career.
- 4:26After university, I did six years in industry and then took a year off and did drone flight
- 4:31controller hardware stuff.
- 4:32And then when that was like coming to an end, when I was going to have to find a new job,
- 4:37I went to Adafruit and said like, hey, I need a job.
- 4:40And they were like, hey, we have this project in mind, our UK doing a project that we want.
- 4:44And it was to do bring MicroPython to their boards that had a different microcontroller
- 4:50than what MicroPython supported originally.
- 4:53So that was in August of 2016 that I started working on the Adafruit version of MicroPython,
- 4:59which then became CircuitPython.
- 5:01So CircuitPython is a fork of MicroPython that originally was for Adafruit's microcontrollers.
- 5:08And we've really pushed it to be really uniform and a good beginner experience.
- 5:13That's kind of how we fit in.
- 5:15Yeah, super interesting.
- 5:16In brief.
- 5:17Well, it sounds to me like with your drone experience and all the small servos and electronics
- 5:23and then this programming background, it's kind of a nice thing to bring together as well, right?
- 5:27Yeah.
- 5:28I mean, I had done Python for a long, long time and I had just gotten into Embedded and
- 5:33I really like that the software depth, so to speak, is like much thinner, right?
- 5:38Like there's a lot less software between the hardware and your code.
- 5:41And I thought that was really cool.
- 5:43And MicroPython was amazing how well it brings Python to those inexpensive devices.
- 5:49Yeah.
- 5:50So MicroPython was first, Damien.
- 5:52And then CircuitPython was forked from it to, like Scott said, to make it work a little bit
- 5:58closer with the Adafruit stuff.
- 5:59Is that sort of the history of it there?
- 6:01Yeah.
- 6:02There's sort of a different focus on the end user and what level of experience you have
- 6:09and kind of what you intend to do with the device.
- 6:12So I see it as MicroPython being used in industry and professionally to build products.
- 6:18And CircuitPython is to support, well, initially to support Adafruit's hardware, but also more
- 6:25for kind of beginners and people who are getting into hardware and want to have a sort of much
- 6:30easier onboarding with libraries and things that are working with the hardware that Adafruit
- 6:36provides.
- 6:37So there's a real distinction there with the audience and therefore the kind of features
- 6:43and things that we focus on.
- 6:45So there's a lot of focus in MicroPython on code coverage and making sure things are really
- 6:52stable or as stable as we can make them across releases so that people who are working with
- 6:58MicroPython in a product can continue to work and be confident that updating will fix bugs
- 7:04and not change other things too drastically.
- 7:07And we get, yeah, we get a lot of sort of requests for features and bug fixes and things from
- 7:13people using it professionally.
- 7:14And so I have to keep an eye out sort of on a lot of all these things so that when they
- 7:19come together, all the people I know who are using MicroPython are not going to suddenly
- 7:24be, have the rug pulled out from under them when they switch to the next version because
- 7:28something else has changed.
- 7:30Right.
- 7:31That's an interesting distinction.
- 7:32The sort of pro production side versus Adafruit is so very welcoming towards this is your
- 7:39first project, your first IoT thing.
- 7:41I like to build something for like a science project.
- 7:44I mean, Scott, maybe you could classify it better.
- 7:46You know, certainly better than I do what the specific focus is.
- 7:50But when I go to Adafruit and I look around, I get this feel that it's very much like these
- 7:54kits and very supportive of getting started and not like, hey, how's your robot doing?
- 7:59Here's where you plug in the thing for your industrial car making robot.
- 8:03I think you're both right on it.
- 8:05I think there's, there's a bit, two aspects to it.
- 8:08One is like the focus that I brought to the project.
- 8:10And I mentioned the TAing, the intro course in university, because I think that does have
- 8:15a lot of influence over how I drive our focus for CircuitPython is like, we're very focused
- 8:20on what that experience in the first five minutes that you've ever programmed, not just hardware,
- 8:25but programming in general, what that first five minute experience is.
- 8:28So we've done things like all of those CircuitPython boards that we now support are all show up
- 8:34as a USB drive once you've put CircuitPython on it.
- 8:37And so all of the tutorials and things that we've written on top of that is uniform across
- 8:41that.
- 8:41And then that dovetails nicely into Adafruit's business model, where they really do focus on
- 8:47beginners, because the reality is, is there's far more beginners than there are intermediate
- 8:52and advanced electronics folks.
- 8:54So from a business perspective, Adafruit's interested in the beginner side, just because
- 8:59that's where the vast majority of people are.
- 9:02Yeah.
- 9:02I also feel like the Zen or the ethos of Adafruit at the beginning was to inspire people getting
- 9:08into programming and getting into hardware, like from the beginning, right?
- 9:12That was sort of almost why it was founded.
- 9:14Yeah.
- 9:14I mean, like Adafruit started around, like it's always been a matter of open source software,
- 9:19open source hardware, and open source tutorials, right?
- 9:22Like Lomor, the founder of Adafruit, who goes by Lady Ada, like she started even before Adafruit
- 9:29was a company, writing tutorials about how people could go get all the parts to build this one
- 9:34thing.
- 9:34So that's very, you know, a lot of what we think about with CircuitPython is not necessarily
- 9:38teaching you new code from if statements and for loops, but actually just getting you all
- 9:42the code to do a project.
- 9:43And then from there, now it's modifying that project in the way that you want rather than
- 9:48starting from a blank screen.
- 9:50Yeah.
- 9:50Yeah.
- 9:50Very cool.
- 9:51Coming out in the live stream, Sean Tibor from Teaching Python Podcast.
- 9:55Hey, Sean.
- 9:56He's a teacher who teaches programming.
- 9:58Also, I know uses some of the Adafruit stuff in CircuitPython.
- 10:01It says the speed from zero to blinky lights is really important for learning.
- 10:04You know, we've got that study from the BBC Microbit where they gave that to, I guess, all seventh
- 10:12graders or something in the UK.
- 10:13I think that's roughly right anyway.
- 10:15And it really changed how many people saw themselves as interested in programming, especially
- 10:21young girls that, well, they're way more likely to take a programming course after having something
- 10:26physical and neat that you can play with rather than just a terminal with a print statement.
- 10:31I think that I agree with that as well.
- 10:33What do you all think?
- 10:33I agree.
- 10:34Getting a blinking light is, it's the hell of a world of microcontrollers, but it's actually
- 10:39really quite hard, you know, whatever your piece of hardware is.
- 10:44So often when I'm making MicroPython work on a new piece of hardware, the thing you can get
- 10:49to is once you can get a blinking LED, then you're sort of set.
- 10:52But getting there is really hard.
- 10:54And I'm not talking actually about blinking an LED in Python.
- 10:57I'm just, you know, blinking an LED however you can in assembly or C or whatever.
- 11:01Because, you know, getting a tool chain working, making this, you know, plugging in the board,
- 11:06powering it up, knowing how to power it up, knowing how to get it into a mode where you
- 11:10can change the firmware on it.
- 11:11These things take, you know, it can take days.
- 11:13I mean, yeah.
- 11:14Or longer.
- 11:15And why is my serial port working right?
- 11:18And, you know, all sorts of stuff.
- 11:20Yeah.
- 11:20So to port MicroPython to a new microcontroller, once you've got a tool chain, a way to flash
- 11:27the device, and you can blink an LED or write characters to a UART, then getting MicroPython
- 11:32working is probably another hour's worth of work.
- 11:34And then you've got, you know, the whole of MicroPython ecosystem that you can play with.
- 11:39But from a beginner's point of view, it's a similar sort of story.
- 11:43When they want to, they get something, they've never done it before.
- 11:46They've got a piece of hardware and, you know, what's going on.
- 11:49So blinking an LED, to get to that stage, there's a lot of kind of conceptual hurdles
- 11:53and also, you know, maybe installing things on your computer hurdles as well.
- 11:57But to get to a blinking LED is really the beginning.
- 12:01And then from there, you can be a whole sort of world of possibility opens up because you
- 12:07can see then how you can turn that into a real life project.
- 12:10Yeah.
- 12:10Start to work with the other sensors.
- 12:12Yeah.
- 12:13Things like the accelerometers or motion or microphone or anything, right?
- 12:19Exactly.
- 12:20Yep.
- 12:20Yeah.
- 12:21I think maybe it makes sense to pause for just a moment and define microcontroller for people.
- 12:27So I have a Mac mini here.
- 12:28It's small, right?
- 12:30That's not a microcontroller.
- 12:31I could get a Raspberry Pi, which is even smaller.
- 12:34Still not a microcontroller.
- 12:36Like, give us a sense for the size of these boards and like, what does the hardware look
- 12:40like?
- 12:40It's not really physical size.
- 12:42A microcontroller itself is actually more complicated than a PC in some sense.
- 12:49A PC like a Mac mini or a laptop or Raspberry Pi that has a CPU in it.
- 12:55And it's connected usually to a keyboard and a screen and maybe some audio and Wi-Fi, some
- 13:02kind of internet.
- 13:02And it's relatively straightforward.
- 13:05It's a CPU that is fast and does a lot of processing and can output to a screen at a
- 13:10high refresh rate and you can interact with it.
- 13:12But a microcontroller is a CPU plus a lot of other peripherals around it, like UART and
- 13:19SPI and I2C and I2S and Ethernet and Wi-Fi and then really low level stuff like DMA and
- 13:27things that make the microcontroller work in a microcontrollery way, timers that interrupt
- 13:33it very precisely.
- 13:34So a microcontroller is what they say sometimes a system on a chip SOC.
- 13:39It's a real tightly interconnected piece of silicon which has a CPU at the center which
- 13:46controls things.
- 13:47But what's more important is the things it's controlling.
- 13:49And it's got to do that in a really precise and real-time way so that what it's controlling,
- 13:56say a coffee machine or an airplane, is guaranteed to work every time the same way and run for
- 14:03years without having any problems.
- 14:05But if you have a laptop and it's probably not going to run for years without needing
- 14:10to be upgraded or crashing for some reason or...
- 14:14It's odd how that works, right?
- 14:15There is this kind of distinction there.
- 14:17It's a bit subtle, but the microcontroller is a really precise machine and a really complex
- 14:24machine in the way it interacts.
- 14:25Would you say more real-time?
- 14:27Yes, that's one of its tasks is to be real-time.
- 14:29And it's not as powerful as a laptop or a PC, but it is more sort of capable.
- 14:36And also programming it is a lot harder.
- 14:39So I think it's important to say that microcontrollers are typically used to do a single task in a larger
- 14:46system.
- 14:46So think of your car and I think a Tesla has a microcontroller that manages the door handle,
- 14:53for example.
- 14:53So microcontrollers are in a lot of things.
- 14:57Damien said toasters in another example.
- 14:59So that means that they're everywhere.
- 15:02You just don't see them.
- 15:04And that has the benefit of being very low cost.
- 15:07So the microcontrollers, which are like the black chip on the circuit playground you see here,
- 15:12they're only like a couple centimeters square.
- 15:14They'll cost under a dollar or a few dollars at most,
- 15:18which means that they're really inexpensive to get into.
- 15:21And in terms of processing power, what you'll see is like if my desktop has 32 gigs of RAM,
- 15:29right, but a microcontroller will have anywhere from like eight kilobytes of RAM up to maybe a
- 15:34megabyte of RAM or a few megabytes of RAM at the higher end.
- 15:38The distinction between like a microcontroller and a microprocessor also involves like how good it is
- 15:42doing multiple things.
- 15:44Specifically, like there's memory protection stuff that will happen in your like desktop CPU that a
- 15:49microcontroller typically cannot do.
- 15:51So really, it's usually just a single task thing.
- 15:54Unlike macOS or Linux or whatever, you've got the OS and then it's running your processes often in user
- 16:01space.
- 16:02They have protected memory.
- 16:03There's a bunch of them.
- 16:04The OS is doing preemptive multithreading, all those kinds of things.
- 16:07This, your Python program, your micro Python or CircuitPython basically is the operating system
- 16:14almost, right?
- 16:15It's like full control.
- 16:16Right.
- 16:19This portion of Talk Python or me is brought to you by Sentry.
- 16:22How would you like to remove a little stress from your life?
- 16:24Do you worry that users might be having difficulties or are encountering errors in your app right now?
- 16:29Would you even know it until they send that support email?
- 16:32How much better would it be to have the error and performance details immediately sent to you,
- 16:38including the call stack and values of local variables and the active user recorded in that report?
- 16:44With Sentry, this is not only possible, it's simple.
- 16:47In fact, we use Sentry on all the Talk Python web properties.
- 16:50We've actually fixed a bug triggered by a user and had the upgrade ready to roll out as we got their support email.
- 16:57That was a great email to write back.
- 16:59We saw your error and have already rolled out the fix.
- 17:01Imagine their surprise.
- 17:02Surprise and delight your users today.
- 17:05Create your Sentry account at talkpython.fm/sentry.
- 17:08And if you sign up with the code talkpython2021, it's good for two months of Sentry's team plan,
- 17:14which will give you up to 20 times as many monthly events as well as other features.
- 17:19So just use that code talkpython2021 as your promo code when you sign up.
- 17:27In some cases, there's a real-time operating system under the hood, but in some other cases, there isn't.
- 17:32Okay.
- 17:32Interesting.
- 17:33So one of the things that might be fun to talk about is we've got MicroPython and we've got CircuitPython.
- 17:41And we've also, you know, when people say Python, they often mean python.org, CPython, Python.
- 17:48They mean you want to start us off with maybe, like, what's the difference between this huge, I don't know how large it is, 40, 50 megabyte thing I download from python.org, and then maybe what MicroPython is.
- 18:01What's the same and what's different?
- 18:03Can I write, can I take a random Python program and run it on MicroPython and so on?
- 18:08It's sort of the biggest thing about if it's called Python, like MicroPython, you know, shouldn't it be just the same as Python?
- 18:14And why can't I just use Python instead if it's the same?
- 18:17Yeah.
- 18:17So to begin with, you can't run Python on a little microcontroller because Python, it uses too much memory is kind of the base, really the reason.
- 18:27Just to load the runtime libraries probably exceeds the entire working memory of some of these chips, right?
- 18:32Just to load sort of the mapping table of Unicode character names is megabytes of data, which MicroPython obviously doesn't support.
- 18:40So one of the main things when I was writing MicroPython was to make sure it didn't use memory where possible.
- 18:48So all of the things that could be put into read-only memory or Flash or ROM were put in there.
- 18:57So dictionaries and modules and things that are sort of built in, like a sys module, all of that is in read-only memory in MicroPython and CircuitPython.
- 19:09Whereas in normal Python, pretty much everything is put into RAM.
- 19:14And so when you make, if you try to run Python on a, CPython on a microcontroller, you would need megabytes of RAM.
- 19:21And that really is the main difference.
- 19:23But then there's a lot of other, you know, things on a sort of a list of things that are different to make MicroPython efficient on a microcontroller.
- 19:31To make it small in code size, to make it run relatively efficiently.
- 19:36And as part of that, we had to make some sacrifices in compatibility with CPython.
- 19:41So there are some things that are not the same.
- 19:43But for the most part, MicroPython and CircuitPython really do feel like normal Python.
- 19:50The syntax is the same, at least up to a given Python version, because Python keeps adding syntax.
- 19:55The syntax is exactly the same, and the semantics of the syntax are the same.
- 19:59And a lot of the built-in types, you know, will have one-to-one mapping with the same semantics and the same methods.
- 20:04So there's a lot of things down there that are very, very similar.
- 20:09And I think that's a lot of things that are very similar to Python.
- 20:12And I think that's a lot of things that are very similar to Python.
- 20:14And I think that's a lot of things that are very similar to Python.
- 20:16And I think that's a lot of things that are very similar to Python.
- 20:18And I think that's a lot of things that are very similar to Python.
- 20:20And I think that's a lot of things that are very similar to Python.
- 20:22I think that's a lot of things that are very similar to Python.
- 20:23And I think that's a lot of things that are very similar to Python.
- 20:23And I think that's a lot of things that are very similar to Python.
- 20:23And I think that's a lot of things that are very similar to Python.
- 20:23And I think that's a lot of things that are very similar to Python.
- 20:24And I think that's a lot of things that are very similar to Python.
- 20:25And I think that's a lot of things that are very similar to Python.
- 20:26And I think that's a lot of things that are very similar to Python.
- 20:27I'm expecting to patch that when we load this module.
- 20:30Yeah.
- 20:31Yeah, exactly.
- 20:32Scott's shaking his head like, maybe not.
- 20:34But even down to things like how division and modulo work with negative numbers is sort
- 20:39of very specific.
- 20:40You know, when you have A modulo B and the negative numbers, then the answer is a certain
- 20:45way.
- 20:46And MicroPython copies that as well.
- 20:47So there's a lot of subtleties there that you may not realize that over the years we've
- 20:52gotten to make sure it's the right same as CPython just because we've got a lot of tests
- 20:56and a lot of people giving feedback when it's not exactly as they expect.
- 21:00Yeah.
- 21:01And yeah, I mean, I've definitely learned so much about CPython and well, the Python language,
- 21:06because so many things I had no idea about.
- 21:08Like, whoa.
- 21:09You had to get the exact nuanced details of how this thing or that thing works, right?
- 21:13Yeah.
- 21:14Make sure it's the same.
- 21:15One of the things that I think is worth keeping in mind as people think about this is when somebody
- 21:19says, I love Python, or I think Python works this way, or Python is this thing and it's
- 21:25productive or it's whatever, it's slow, it's fast.
- 21:28They often can be talking about many things.
- 21:30Somebody could say, I love Python and they mean the Python syntax.
- 21:33Somebody could say, I love Python, or I get the standard library so cool that it comes with
- 21:36all of these things in the standard library.
- 21:38They could mean IPIP installed pandas and requests and now something cool happened.
- 21:43Yeah.
- 21:44Right.
- 21:44When you say Python runs there, there's like, you kind of got to say, okay, well, what are
- 21:49we talking about?
- 21:50Right?
- 21:51It's mostly the language for sure, but there's got to be a ton of standard library things that
- 21:56don't make sense.
- 21:57I think that's one about parsing CSS hex values.
- 21:59Like who cares?
- 22:00Tk enter.
- 22:01Don't care.
- 22:02Yeah.
- 22:03SQLite maybe?
- 22:04I don't know.
- 22:05I did actually do a lightning talk at the last language summit, kind of on this topic.
- 22:10Perfect.
- 22:11And like Damien was saying, like, to his credit, MicroPython is Python in the core syntax areas
- 22:16and the built in types.
- 22:17But as you kind of grow outwards into like the standard library, things get omitted a lot
- 22:22because the, frankly, the standard library in CPython is large.
- 22:26Yeah.
- 22:27And so I did kind of a comparison there and I can share people with the slides, but like,
- 22:31take all this stuff in CPython and show what's in circuit Python.
- 22:35That's cool.
- 22:36I've been having like discussions off and on with Brett Cannon about this as well.
- 22:40Cause he's been thinking about like, how would you define like a minimum version of Python?
- 22:44And I think that MicroPython did such a great job of that.
- 22:47It feels like Python to me.
- 22:48I had the background in Python before.
- 22:50So like coming to MicroPython, it felt very natural.
- 22:53So I think we're a good case for that.
- 22:55Yeah.
- 22:56I think you definitely are.
- 22:57You know, Brett was, I know he's been thinking a lot about WebAssembly and what would it look
- 23:02like if we could have Python and WebAssembly and we could have it in these other,
- 23:05you know, like what would a mobile Python look like and these different environments that are
- 23:09not just desktops plus servers and having this standard core Python subset is a pretty neat idea.
- 23:17Yeah.
- 23:18A couple of things from the live stream.
- 23:19Sean has a warning for everyone who gets into this, that these microcontrollers tend to multiply
- 23:24quickly.
- 23:25He started with just one or two.
- 23:26Now he has a whole collection.
- 23:27I can't see what's in your background, Damien, but Scott, you seem to have a bunch of these things
- 23:32gathered around.
- 23:33Oh yeah.
- 23:34This room is a mess right now.
- 23:36I probably have at least a dozen on my desk though as well.
- 23:38Yeah.
- 23:39There's, I just got to find new and inventive ways of actually organizing them.
- 23:44Cause you know, I mean, there's things like, you know, a box full of dev boards sort of in
- 23:50plastic blister packs.
- 23:51I take them out of the blister packs are too big.
- 23:54I try to take those out.
- 23:55Yeah.
- 23:56Oh my gosh.
- 23:57I have bins per manufacturer.
- 23:58So like STM, NRF, Atmel, of all the different development boards.
- 24:03Yeah.
- 24:04Yeah.
- 24:05There's just, yeah, there's a whole lot of stuff everywhere.
- 24:07Like just, just, they're inexpensive.
- 24:10They're impulse buyable, which is bad.
- 24:13Exactly.
- 24:14I'm going to buy those and one of these and yeah, amazing.
- 24:16But it's gotta be a collection of cool little things.
- 24:18Yeah.
- 24:19It's also important to figure out like what each individual microcontroller can do unique,
- 24:24uniquely.
- 24:25Mm-hmm.
- 24:26What makes something unique?
- 24:27Like it's obvious, like if it's a BLE chip, then that's obviously what you want to do.
- 24:31If it's wifi, that's what it can do.
- 24:33But the RP2040, which is the new chip from Raspberry Pi, like they have this really weird,
- 24:38unique peripheral that allows to do really, really, really real time stuff because an actual
- 24:43CPU and a microcontroller is still not perfectly real time.
- 24:46So they have this like special thing that they added that can do some really impressive
- 24:50real time stuff.
- 24:51It's very interesting to see like the stuff that's standard between all these things.
- 24:54And then what's different.
- 24:55Yeah.
- 24:56I can imagine.
- 24:57One more interesting thing I want to ask you about from the live stream.
- 25:00Tim out there asks, you know, what are your thoughts on circuit Python being used in TI
- 25:04calculators?
- 25:05So the new TI 84 comes with programming as, and you can write Python in here.
- 25:13I don't remember what the, oh, here it is.
- 25:14The programming bits where you can see, but yeah, I mean, I remember programming in calculators
- 25:20being like really, really weird.
- 25:22Yeah, I did that actually.
- 25:24Yeah.
- 25:25I mean, a little bit funky, but you know, having Python there is quite neat as well.
- 25:29And yeah.
- 25:29So this is a fork of circuit Python.
- 25:31Interesting.
- 25:32It's not publicly released, which is totally okay.
- 25:35They are careful not to call it circuit Python, which is good as well.
- 25:38But that does mean that like, if you go to circuit Python.org slash downloads, you won't
- 25:42find like the latest version of circuit Python for your calculator.
- 25:45But generally, I think it's great.
- 25:47Like, I love seeing people build on circuit Python, just like we've built on micro Python.
- 25:52Like, yeah, people should do that.
- 25:53It's really neat.
- 25:54Yeah, absolutely.
- 25:55And then another one out there that's neat that says, Matt says, "Micro Python and the
- 25:59new Lego spike delighted the inner teenager in me."
- 26:02Did you catch that?
- 26:03You must've known about this, right?
- 26:04Yes.
- 26:05How do you take this news?
- 26:06Yeah, that was pretty amazing.
- 26:08I don't know if it was a year or a couple of years ago, I think, maybe even longer, three
- 26:12years ago.
- 26:13Yeah, a little while.
- 26:14When they started, well, they contacted me about it.
- 26:16So it's still an ongoing thing.
- 26:18You can, there's a Lego education, which is separate to sort of Lego retail.
- 26:24Lego education is for schools.
- 26:26I remember using that when I was in high school a long, long time ago.
- 26:29Lego, it's obviously Lego, but it's the different kit and it's different focus on what you do
- 26:33with it.
- 26:34And the Lego education these days, sort of the new version of Mindstorms uses MicroPython
- 26:39in the hub of the sort of the central processing unit of the central sort of Lego control block.
- 26:45Do they expose that to the kids to play with or is it just like a runtime internal sort
- 26:50of thing?
- 26:51It's kind of both.
- 26:52The thing that you can get for Lego education is using MicroPython to implement sort of what
- 26:58what the kids say.
- 26:59But I think there are plans to make it so that you can actually use MicroPython directly.
- 27:03That'd be really neat.
- 27:04Yeah.
- 27:05Very cool.
- 27:06I think it's great.
- 27:07Scott, I asked about the comparison between MicroPython and CPython.
- 27:11You want to close the circle and go from maybe the differences of MicroPython and CircuitPython.
- 27:17Like, why are there two things here and whatnot?
- 27:21How people think about like, if I'm going to work with one or the other, where would they go?
- 27:25Yeah.
- 27:26So I think the why is what Damon iterated earlier is like our focus in CircuitPython really is
- 27:31beginners.
- 27:32And coming into Adafruit, I also knew that their model is that like for every device that they
- 27:39sell, they provide example code and drivers for it.
- 27:42And because Adafruit was going to do this for the Python world, we had to make sure that the
- 27:46hardware abstraction layer, like the modules you import in Python that allow you access to
- 27:51the hardware would be consistent across everything that runs CircuitPython.
- 27:54So you saw me get like a little niggly about like, it's not actually CircuitPython on the TI
- 28:00calculator because like, I think the branding of CircuitPython is really important because it means that
- 28:05you can download it from the website.
- 28:07You can use the APIs that we have standard as CircuitPython.
- 28:10And therefore, all of our CircuitPython libraries work on top of that.
- 28:14All our guides for CircuitPython work on top of that.
- 28:16Yeah.
- 28:17So that was really, you know, one of the more important things for us is having that uniform
- 28:21API that we can then build all of this Python software on top of.
- 28:24That's one of the main differences.
- 28:26It should be, I should say that we do actually have this layer called Blinka now that allows
- 28:31you to use MicroPython under the hood or actually CPython under the hood.
- 28:35But it presents that same CircuitPython API for other things as well.
- 28:39This line has been blurred some.
- 28:41The thing that doesn't come with that is that we, in CircuitPython, we still do ensure
- 28:46that your kind of workflow is the same as well.
- 28:48So all of the CircuitPython boards that you can download now, except in the future, this
- 28:53is going to change, show up as a CircuitPy drive and you can edit the code.py file on it.
- 28:58It runs after you save it automatically.
- 29:01And it's really quick and easy to iterate on.
- 29:03Right.
- 29:04So basically there's a file watcher that looks at your source file that is the program.
- 29:08And if it sees a change, it kind of just reboots super quick and reruns it, right?
- 29:12It's not even that smart.
- 29:13It's any write to the file system.
- 29:15It doesn't know what file you're writing to.
- 29:18It's just any write will trigger that.
- 29:20And the caveat I had is I'm working on a Beely only workflow as well.
- 29:24So in the future, there will be two ways of using CircuitPython.
- 29:27There will be a USB way and a Bluetooth low energy way.
- 29:31I see.
- 29:32So you don't have to actually connect physically to the thing.
- 29:34It could be over there.
- 29:35Right.
- 29:36You could program it.
- 29:37That and from phones, phones and tablets in particular.
- 29:40Devices that are really easily interoperable over USB.
- 29:44We want to bring the beginner experience of programming in CircuitPython to those devices as well.
- 29:49Yeah.
- 29:50So that's the caveat.
- 29:51Like right now everything does USB, but I'm like working on the micro:bit v2 right now that will not be doing USB.
- 29:57It'll only be doing Bluetooth low energy.
- 29:59That sounds more complicated.
- 30:00Yeah, it is.
- 30:01But also very useful.
- 30:02But I just, without a wire, you know.
- 30:04Yeah.
- 30:05I'm just thinking of when my headphones like get disconnected.
- 30:07I'm like, oh, interference.
- 30:08How frustrating.
- 30:09And, but you know, when that's your connection, right?
- 30:11Yeah.
- 30:12Bluetooth's come a long way and I have had it working a bit.
- 30:14A lot of the challenge with Bluetooth is there's no standard way of doing like file transfer.
- 30:19So we really like we're working on apps to be able to transfer files and apps that are letting you pull that will pull down all the example code and automatically load that over.
- 30:30And that file transfer API that we have is all public.
- 30:33So if folks want a link to that, I can send them a link to that protocol.
- 30:36So yeah, there's a lot more work off the device to do for it for this Bluetooth stuff.
- 30:41That's cool.
- 30:42So I see on circuitpython.org, it says Blinka and circuit Python libraries are just a pip install away.
- 30:48So if I'm working, but I'm on my desktop machine or server machine, can I still do like prototyping and try the libraries?
- 30:56What does that mean?
- 30:57It's not every computer.
- 30:59If you're on a Raspberry Pi, it will work because that is supported.
- 31:03If you actually, I think if you click that single board computers link, it'll show you all the ones that we specifically support.
- 31:09But single board computer is like a Linux class computer that usually breaks out general purpose IO, GPIO.
- 31:17So that's kind of the class of Linux computers that you'll be able to use this on.
- 31:21Okay.
- 31:22And then we do also have a couple cases where you could like plug something into your USB that would also like give you that GPIO on another device.
- 31:32This portion of Talk Python To Me is sponsored by Linode.
- 31:36Visit talkpython.fm/linode to see why Linode has been voted the top infrastructure as a service provider by both G2 and TrustRadius.
- 31:44From their award winning support, which is offered 24/7/365 to every level of user, to the ease of use and setup.
- 31:52It's clear why developers have been trusting Linode for projects both big and small since 2003.
- 31:57To pull your entire application stack with Linode's one-click app marketplace or build it all from scratch and manage everything yourself with supported centralized tools like Terraform.
- 32:07Linode offers the best price to performance value for all compute instances, including GPUs as well as block storage, Kubernetes, and their upcoming bare metal release.
- 32:17Linode makes cloud computing fast, simple, and affordable, allowing you to focus on your projects, not your infrastructure.
- 32:25Visit talkpython.fm/linode and sign up with your Google account, your GitHub account, or your email address and you'll get $100 in credit.
- 32:33That's talkpython.fm/linode or just click the link in your podcast player show notes.
- 32:38And thank them for supporting Talk Python.
- 32:41Question from the live stream from Tim again.
- 32:45How has the workflow changed over the past few years for SugarPython and MicroPython when deploying code?
- 32:50And it sounds like Matt's talking about MP remote.
- 32:54Tim, do you want to talk about what the deployment looks like?
- 32:57Yeah, there's a lot of answers to that question from a MicroPython point of view.
- 33:03As I mentioned, if you're using MicroPython in a product, then it's a really different setup as if you're using it in a hobby, trying to make your light turn on and off.
- 33:13So using it in a professional setting, you'll probably have a big sort of workflow or setup where you can freeze the code into MicroPython and deploy it or something like this.
- 33:24Yeah, in production, what do you put actually on there?
- 33:26Do you put, would you go and say, well, we're going to put a PYC file there instead of the Python file?
- 33:31Yeah, yeah.
- 33:32Or is there stuff like that you might do?
- 33:33Yeah, it's not, we have our MPYs sort of instead of PYC, precompiled code, yes.
- 33:39But there's sort of another, a further step where you can take precompiled code and then sort of freeze that into a C data structure, which becomes part of the firmware itself.
- 33:48So big projects might have hundreds of Python files, which are then all precompiled and frozen and then built into the firmware and then deployed onto the device.
- 33:55Is there any room for something like Cython or number or some one of these C compiler type things?
- 34:01Yeah, Cython don't really support that.
- 34:04But you can write C code as well if you need to, if you really need speed, you can implement a module in C and then tie that into Python quite easily.
- 34:13So there are lots of options in terms of making things faster or efficient or the way you do your workflow.
- 34:20But sort of to get back to the original question, MP Remote is a new tool that was released in the last version.
- 34:26And it's intended to make a workflow, well, give you more options.
- 34:32You can use it to copy files on and off, get a REPL on the board, or one of the main features is to mount.
- 34:39So make your PC's file system available on the device that you're running on.
- 34:45So you mount your PC's file system on your PI board or ESP32 or whatever.
- 34:52And then when you go onto the board and do it OS.Lister, you actually can list the files on your PC running on the board.
- 35:00So this allows you to basically do all your work on the PC and then your board can import and run code from the PC, read and write files from the PC.
- 35:11And so the workflow is very quick.
- 35:13And when you're sort of happy, you can then precompile or copy files, MPY files onto the board to run it disconnected from the PC.
- 35:22Yeah.
- 35:23This is also good for sort of testing integration tests of devices.
- 35:27They can sort of interact more closely with the PC that they're testing against.
- 35:32And yeah, it just aims to provide you with more tools at your fingertips to make your workflow more productive.
- 35:38Yeah, it's neat.
- 35:39When I want to put something onto my server to, you know, to upgrade like for site, something like that.
- 35:46I'll do some work locally.
- 35:47I'll do a git push.
- 35:48Some magic will happen.
- 35:49GitHub will do a webhook back over to the server.
- 35:52The server will grab that.
- 35:54It'll pull it down, install the new dependencies, restart the server through like a zero downtime sort of firewall type of thing.
- 36:01If I have a robot in a factory, what do I do?
- 36:04Is there a continuous deployment equivalent for MicroPython things or what's the story look like over there?
- 36:10That's a good question.
- 36:11We don't, we don't.
- 36:12I think this came up the last time we had a couple chats between like the folks that work on CircuitPython and the folks that work on MicroPython.
- 36:20And I think this was kind of a topic that we all said like, yeah, that would be really nice.
- 36:23We don't have a sort of recommended or official way to do all of that.
- 36:28But what I guess what you're talking about is over the updates maybe kind of answers your question.
- 36:33Yeah, basically.
- 36:34Yeah.
- 36:34Like if I had a Tesla, it sometimes I wake up in the morning, maybe my Tesla does different things.
- 36:39It's something like that.
- 36:40Yeah.
- 36:41MicroPython things.
- 36:42Well, if you have a factory full of robots, you probably don't want them to automatically update because you, you need to be there when it happens and you need to control it and do it at the right time and so on.
- 36:52Yeah.
- 36:53It really depends heavily on the project that you have.
- 36:55But over the updates are sort of definitely, yeah, the way to do this and they have been done and they are sort of out in the field.
- 37:03And they're done in lots of different ways, like some over Bluetooth where you download the new firmware and then.
- 37:09It's a little like what Scott's working on now.
- 37:11Yeah.
- 37:12Yeah.
- 37:13Sort of an automated way to install the new code and then reboot.
- 37:16But, and then other places where it's, they're connected by a USB and you can just do a normal DFU upgrade or similar, or maybe over I2C they're listening in a special mode to download new code.
- 37:27There are, there are lots of ways to do it and there are lots of sort of parts in MicroPython's code that allow you to do it.
- 37:34And it really depends on your project.
- 37:36I think probably Scott has a different answer.
- 37:38I was going to say from the hobby side, like it's never, I don't, we don't focus on the automated update story.
- 37:45But you know, a lot of the folks that use CircuitPython are coming from an Arduino world.
- 37:50So Arduino is really common hobby.
- 37:53It's based on C, but it's got some like stuff on top of the C stuff.
- 37:57But it means that you have to like have a computer that has Arduino installed that can compile the source code.
- 38:02And because we focus so much on this interaction of like, it shows up as a USB drive.
- 38:07It actually means that anybody, it makes it more accessible to update.
- 38:11So if, if I'm remote and somebody wrote the software for me once, but now they want me to update it.
- 38:16Like, even though I don't understand how it's doing, I can plug it in, it shows up as a drive and I can copy files over.
- 38:22So it's really has been beneficial for, for folks that way, whether it's the Python code they're updating, or a lot of our boards also come with a bootloader,
- 38:31which is like the software that manages what you're installing.
- 38:34And a lot of our bootloaders for devices also show up as a drive as well.
- 38:38So it's still a manual process, but it's a manual process that's gotten better from, from the previous things.
- 38:44Right. And from the hobby perspective, you could have a little app or something that says, oh, I noticed we're connected to this thing and we're just gonna, it's out of date.
- 38:51We're just going to push some stuff to it.
- 38:52Yeah.
- 38:53We actually have some community members who've really fleshed out this app called Circup, C-I-R-C-U-P, which you can pip install.
- 39:01And that will like figure out all the libraries on your circuit-py drive that are out of date and update them for you.
- 39:06Okay.
- 39:07Which is pretty neat.
- 39:08Yeah.
- 39:08It's kind of like the pip of circuit-python.
- 39:10Yeah.
- 39:11I'm just sure the requirements and concerns are extremely different.
- 39:14if you're working with, you know, a small hobby device versus something that is controlling a robot or runs a thing that shouldn't go down.
- 39:23Yeah.
- 39:23So one thing I wanted to definitely focus on while we were here together, seeing I find it is somewhere, is I do now this.
- 39:30The, there's a lot of work that has been done.
- 39:33It sounds to me like on the circuit-python side to catch up with micro-python.
- 39:38Is that right?
- 39:39Mm-hmm .
- 39:39You want to tell us about that, Scott?
- 39:40Yeah.
- 39:41So the history of this is like when Adafruit started paying me to work on what became circuit-python, it was like, okay, I'm going to write a whole lot of code, right?
- 39:49So that's when on GitHub I hit fork.
- 39:51That's when I add a new port for atmels.md.
- 39:54And that's kind of when we split.
- 39:56And later on we decided like, oh, you know, like we have enough changes here that it would be a lot of work for both Damien and us to get those changes merged back together.
- 40:06And that's still very true.
- 40:07But what I said at the time was that we would kind of keep pace for every stable release that we do.
- 40:13Keep pace with stable releases from MicroPython.
- 40:15That wasn't true for about like two or three years.
- 40:18We stopped updating.
- 40:20We do.
- 40:21It's basically a git merge, right?
- 40:22So it's a whole lot of work.
- 40:24And so I did, we had six versions of MicroPython to merge in.
- 40:28So I did those.
- 40:29That's like 112 through 115 or 110, something like that.
- 40:35And then since then we've actually updated 116 as well.
- 40:38So what's involved with that is like MicroPython has both like a PI folder, which you can think of as kind of like the VM.
- 40:44We think of that as kind of the core.
- 40:46And then there's separate ports for each main type of chip that we support.
- 40:50And we don't really share code with MicroPython for those different implementations for different chips.
- 40:56But we do share that core Python VM.
- 40:58So a lot of the work to merge in MicroPython is like updating all of that core stuff.
- 41:03And the discussions that Damien and I have had along with the other folks that work on these two projects has been like, all right, like what can we do just to get back to this world where we have the same copy of that PI folder?
- 41:16Yeah.
- 41:17Because there's like a few weird things that like CircuitPython has done that haven't been merged back into MicroPython.
- 41:23And we've had discussions about which things are those are interesting and which ones would we want to make configurable and things like that.
- 41:29Yeah. Interesting.
- 41:30Now that we're updated, we have this foundation where we can have this discussion again, because we actually can tell like what the differences are between the two latest versions of these projects.
- 41:39Yeah.
- 41:39Yeah.
- 41:40Larry Bank out of the live stream says my imaging codec still haven't been merged into MicroPython.
- 41:45There's a lot of things that haven't been merged into MicroPython.
- 41:48Yeah.
- 41:48David, I was going to ask you, you know, what does this mean for MicroPython?
- 41:51Like, obviously, it makes sense for CircuitPython to just not be out of date.
- 41:55And, you know, the farther you are away from one of these merges, it's more like credit card debt.
- 42:00And then a little bit is fine.
- 42:01But as it gets farther, it starts to become a problem.
- 42:04But in reverse, there's probably a lot of things that people who are engaged on the CircuitPython side could bring back if it was basically the same.
- 42:12There's some great things that CircuitPython Scott has done with garbage collection for one thing.
- 42:17And it would be great to share a common PY folder at least.
- 42:21And we have, as he said, we've had discussions about sort of how we can smooth things or make things more common and where we know we differ, you know, how we can make it easier that we differ.
- 42:33Recently, actually, a really good improvement in MicroPython for tab completion so that it didn't have complete underscore and also tab completed imports.
- 42:42You do imports based tab and then it lists the tab completes the things you can import.
- 42:46Some good improvements for sort of fuzzing and sanitization addresses and sort of various subtle bug fixes that have come across.
- 42:55So it's, yeah, look, it's really great to have an open source project.
- 42:58And because other people find bugs for you and fix them.
- 43:02Yeah.
- 43:03The more we can be in line, the better.
- 43:06And there are actually other, I mean, there are other people using MicroPython and CircuitPython as we saw with the calculator and Lego.
- 43:12Yeah.
- 43:13And I think in the early days I was happy people were using MicroPython and wasn't too concerned about sort of people forking and changing things.
- 43:22But these days my, I've shifted more towards, well, what can MicroPython do to make it easier for other people to use it without changing it?
- 43:31So when they're about to think maybe I need to fork this to do this, you're like, well, why are they about to push that button?
- 43:36What can we do to make it more extensible or whatever it needs to be, right?
- 43:40Yeah.
- 43:41We're going to make someone else's life easier so they don't have to fork.
- 43:44Not that we want to accommodate everybody and we can't, but, you know, does it make sense to talk with these people and then make sure that their needs can be met in a sensible way and maybe it helps everyone else as well.
- 43:57So, yeah, it just, it helps the community when you have less sort of forking and more cohesion.
- 44:03Yeah, it absolutely does.
- 44:04I mean, we've seen the Python 2, Python 3 stuff mostly get resolved by people finally moving all onto the same place where the core devs spend their time.
- 44:12And I think that that's, it's only been beneficial.
- 44:15It seems like a lot of projects are taking some of these ideas and picking up speed, whereas there used to be a lot of hesitancy as there's like too many different paths in the road.
- 44:23Yeah.
- 44:24Well, I'm just glad I did Python 3 from the beginning with MicroPython.
- 44:29I bet you are.
- 44:30I was just playing around with this.
- 44:33I was able to use like a smiley face emoji as a variable name and it just worked, which kind of blew my mind.
- 44:40So that's a super credit to Damien for making MicroPython really, really strong, really robust and really Python.
- 44:47Yeah.
- 44:48I think, you know, in terms of like CircuitPython and MicroPython, another thing that we can really compliment MicroPython with is like, we can, we're willing to be more experimental.
- 44:57Damien alluded to this memory allocation thing that he, I pitched to him at one point and he was like, "Ugh."
- 45:02I was like, "Well, we'll put it in CircuitPython, we'll see how it goes.
- 45:05And then you can decide whether you want it or not."
- 45:07So I think that's a benefit that we can have in CircuitPython is that like, because Damien really wants MicroPython to be stable, we can, we can try things out in CircuitPython.
- 45:16And then he can pick the things that he wants to move into MicroPython.
- 45:19That's a fantastic way to look at it.
- 45:20And the fact that you've got these merge differences, these version differences down to such a small gap.
- 45:27But like, well, that would have worked three years ago.
- 45:29I'm not sure it works now.
- 45:30Now you're basically experimenting on what is the real thing.
- 45:33Yeah, that's helpful for like this tab complete thing where like, somebody added it into CircuitPython and we merged it, but then they also made a pull request to MicroPython and like, making sure that they're starting from a closer baseline will help everybody as well.
- 45:47Yeah.
- 45:48I mean, it's, it was, it was really good to hear you do 1.16.
- 45:51And we're trying hard for MicroPython side to release every two months or so, so that it's easier for everybody to upgrade and thing.
- 45:58It doesn't take so long for a new release to come out.
- 46:00Yeah.
- 46:01And what's the schedule for CircuitPython, Scott?
- 46:03We don't have a set timeline.
- 46:04We do try to get in a rhythm of, of doing, we do both stable and pre-release releases.
- 46:10And we don't have kind of a fixed schedule, but we, we tend to try to have like pretty recent pre-releases out.
- 46:18If it's been long enough that we're recommending the pre-release over the stable release, we ask ourselves like, okay, why aren't we just calling this a stable release?
- 46:26Right.
- 46:27That gives us a forcing function to up the stable release.
- 46:30We are kind of in this window between major releases.
- 46:33So we're currently like doing 7.0 stable or pre-releases for that.
- 46:39That's a chance when we did all these merges, because we get a lot of instability, not because the code we're merging in is bad, but the merge is really hard and it's hard to get correct.
- 46:47So we're kind of in this like very big state of flux right now with CircuitPython where a lot of things are changing and we're very quickly approaching this.
- 46:56Like, all right, we got to stop changing things so that we can stabilize because we're no longer recommending the stable release.
- 47:02We're recommending the pre-release.
- 47:03Yeah.
- 47:03Because like when you, somebody introduces a new board and it's like, oh, well, that new board is not supported in the stable release.
- 47:09You have to use the pre-release.
- 47:10Like that's a largely a forcing function for us.
- 47:13Interesting that the hardware is driving the software like that.
- 47:15Yeah.
- 47:16And that's a thing from like a number of us are funded by Adafruit to work on it.
- 47:20So when Adafruit releases new hardware, we have to decide like how we're going to make it available.
- 47:24Absolutely.
- 47:25All right.
- 47:25Let me take one question from the live stream.
- 47:28This is from Murray.
- 47:29Hey, Murray.
- 47:30I don't actually know the details, but I'll read to you.
- 47:32I'm sure you all do.
- 47:33Here's a different question.
- 47:34What's the state of MicroPython dash lib project as regards to the bigger MicroPython project?
- 47:37That's a good question.
- 47:39The aim is to switch to, you know, improving MicroPython lib.
- 47:44It languished a bit because, well, there was just a lot of stuff to do in the main repository.
- 47:50But now that a lot of the code in the main repository has sort of stabilized and settled down and mature, there's more scope now to go and write everything.
- 48:02Well, write all the extra bits in Python and put them in MicroPython lib.
- 48:06So we have recently reorganized that repository to be a bit clearer as to what's in there.
- 48:11And the aim is to maintain it and keep it running and put lots of libraries in there, improve the CPython standard library support and other things.
- 48:23There you might have noticed there was AIOBLE, which is a asynchronous Bluetooth library, which is in MicroPython lib and is being used in production.
- 48:35It's pretty good in terms of stability.
- 48:38It's very good in terms of features and what it can do.
- 48:41It's really quite amazing how it makes Bluetooth simple, which is a very asynchronous thing and a very high latency thing.
- 48:49So having an asynchronous API is really beneficial.
- 48:53So that's just one example of a library that is written in Python, pure Python, and is in MicroPython lib.
- 49:00And we aim to continue that trend.
- 49:03I know that it's a little bit stale some code in there, but we will fix things in the very near future.
- 49:11Yeah.
- 49:12Yeah.
- 49:13Very neat.
- 49:14Speaking of asynchronous, what are some of the, this question, both of you, what are some of the shiny language features that are new and neat in there?
- 49:21Like asynchronous awake?
- 49:22Can I do that with the Bluetooth library or Walrus?
- 49:25Can I do a Walrus operator?
- 49:27What's going on?
- 49:28Like, what can I do?
- 49:29I think it's a micro async.io, which has, is in its third sort of iteration, third version.
- 49:36And that's been, I think about a year old now, that version.
- 49:40And that also has been used in quite a few production systems.
- 49:44that's also quite stable.
- 49:47And I think is a really good showcase of using Python on microcontrollers because things on microcontrollers, well, some things take time, like reading a sensor and waiting for a Bluetooth packet to arrive.
- 50:00And you've got to do lots of things at once, like blink a light to indicate progress.
- 50:04It'd be great to be able to take them as those events come in, right?
- 50:07Yeah.
- 50:08So event based, but also easy to sort of use because I mean, multi threading using, you know, threading in Python, you can do, you can do that on some micro Python ports, but it's heavy weight in the sense that it uses a lot of memory for each stack, a stack of each thread.
- 50:25And it's slow to switch and respond.
- 50:27So it's, it's, it's not a great solution.
- 50:29So cooperative multitasking, which is what asyncio is, is I think a better solution than threading on a microcontroller and even on a desktop.
- 50:38Yeah.
- 50:38And it works really well.
- 50:40When you have something that's well suited to asyncio, it's really, it's a really fun experience to program something that way.
- 50:46It's aptly named because what it's really well suited to is waiting on things like IO, right?
- 50:52Right.
- 50:53Waiting on these devices, these various sensors and stuff to come back and just say, Hey, I've got an input.
- 50:58I've got a call back or whatever.
- 51:00Right?
- 51:00Like that's, it seems like the perfect case.
- 51:02It's not like, well, we're trying to do all this computational stuff.
- 51:05Asyncrasy.
- 51:06Well, that doesn't work as quite well that way.
- 51:08Yeah.
- 51:09Like, you know, you may just want to wait for a pin to change from high to low.
- 51:12So you spawn a task and you do, you know, a weight on the pin.
- 51:16And then when that, when that statement continues, it means the pin has changed.
- 51:20That's hard to do in a sort of callback based system.
- 51:24well, it's not, I mean, it's just a different conceptually and maybe it's harder to reason about things.
- 51:29So there are, there, yeah, we have support for these fancy features, asyncio and the walrus operator we had in f-strings and not yet, you know, I think circuit Python has f-strings.
- 51:39Oh, you guys already have the f-strings.
- 51:41Damien has a higher bar for merging than we do.
- 51:43Interesting.
- 51:44So in circuit Python side, we have f-strings merged in, but we haven't done this work on the async stuff that Damien's really done.
- 51:50Because our audience's beginners are really pushed us not to do async stuff.
- 51:54Because I think something that beginners don't necessarily understand is like the computer literally does things in order that you want it to do.
- 52:00Yeah.
- 52:01So a lot of the examples that I, that would, that we use and that we get to people to doing is just doesn't use async.
- 52:07So it's not been a focus of ours.
- 52:09So I think that's a lot of the reasons to merge was to get the newer async stuff in and kind of hope that somebody would come along and turn it on and make sure it's all working.
- 52:17But kind of, we've had the opposite, opposite approach.
- 52:19And I think talking about async, one of the things that we've been thinking about is like, async is very networking oriented in terms of Python.
- 52:29And it's not necessarily clear how that impacts hardware APIs and like waiting for pins and things.
- 52:34So I think it's really interesting to think about how async await applies to things like spy transactions and I squared C transactions.
- 52:41And, and what exactly like, like we, I talked about how circuit Python has a different hardware layer than micro Python does.
- 52:48And like, I don't think either of us have really come up with a, like, what does that look like when you have async await support?
- 52:54So I'm curious to see what, what Damien comes up with.
- 52:57Yeah.
- 52:58I mean, we do, we have recently merged I2S support, which has preliminary asyncio support in it as well.
- 53:04So you can, yeah, asynchronously send and receive audio buffers.
- 53:09We also have async support for pins using, well, a small sort of piece of wrapper code.
- 53:15A thread safe flag is our main sort of interaction between interrupts and asyncio.
- 53:19So you create a thread safe flag object on the asyncio side, you can wait on the flag and on the IRQ side.
- 53:26So some event happens like a spy transaction completes and you get an IRQ and then you can set the thread safe flag.
- 53:32And then that will mean that the task waiting on that can continue.
- 53:37So, yeah, but I agree, Scott, that it's still early days with API for connecting IRQC and things like that into the async world.
- 53:45I know one project sort of working on uses asyncio and Bluetooth and thread safe flag with pins, but nothing else is async.
- 53:55But the things that are async are very important to be async.
- 53:58And a lot of the time just asyncio.sleep is the thing you want.
- 54:02And yeah, just wait, wait for a bit of time.
- 54:04So you're waiting on a PNN sleeping is actually gets you a long way.
- 54:07So, but I think it's still early days and even asyncio in CPython is sort of still early days in the sense that they're still trying to work through what API is good for streams.
- 54:18And there's trio as well, which is providing good feedback to see Python on asyncio.
- 54:25So it's still early days in the whole sort of Python space.
- 54:30Yeah.
- 54:31There's my favorite unsync, which is a unification layer on top of threads, multiprocessing and asyncio.
- 54:38And it's like, I think the whole implementation is 126 lines of Python in one file, but it's, it's glorious.
- 54:45All right.
- 54:46One final topic I want to touch on.
- 54:48There's been a lot of interesting work about making Python regular old server side, desktop side, CPython faster.
- 54:55There's been a bunch of interesting things coming on.
- 54:58Pigeon from Microsoft is kind of making a comeback.
- 55:01I think Anthony Shaw is doing some work on that.
- 55:03Maybe Brett Cannon as well.
- 55:05There's Cinder.
- 55:06The Instagram crew has released with really interesting stuff going on about making a lot of interesting changes in the runtime about making it faster stuff about like immortal instances that are sort of not subject to GC and reference counting and whatnot.
- 55:23We've got the latest language summit, you know, is talking about interesting things he's doing and focusing on to try to sort of accomplish the same goal.
- 55:32Like, is any of this stuff influencing what you all are thinking about?
- 55:35Or is it just not really applicable?
- 55:36Yeah, this is a really big topic because Python has a long history and it's used in a lot of places for a lot of different things.
- 55:44And it's built by a community, unlike other languages.
- 55:48I mean, yeah, lots of languages built by communities, but Python in particular is one of the more popular languages that is really just community run and funded.
- 55:56You might say it as something like it's built by a very diverse community, technically speaking, as opposed to say JavaScript, which is almost always web.
- 56:05And then kind of recently, it's been a little node, but like it's astrophysicists, it's embedded, it's data science, it's web.
- 56:11Like there's a lot of different pressures and areas that Python gets put in.
- 56:15Yeah.
- 56:16And, and the focus has not been on performance.
- 56:19It's been on usability and features and keeping it up to date.
- 56:23Backwards compatibility.
- 56:24Yeah.
- 56:25Yeah.
- 56:26I mean, it's been, it's such a, it is an old language that has evolved a long way.
- 56:30Like C is an old language, but C hasn't changed that much.
- 56:33C++ is an old language.
- 56:34Well, C++ has changed a lot, but it's got a very big community around it and lots of production.
- 56:40But Python is sort of, yeah, it's got such an sort of amazing and passionate community who do all this stuff for free.
- 56:46And performance is something that's sort of always been in the back of people's minds, but it needs a lot of work and it kind of needs a stable Python language to perform.
- 56:54You know, you can't optimize along the way of adding features.
- 56:59It's really hard.
- 57:00But anyway, this is sort of just to say that it's a big topic and lots of people have tried to make Python faster.
- 57:07Python faster.
- 57:08And PyPy is an amazing piece of software that makes Python faster.
- 57:12One of my first big Python projects, we used PyPy because it was really, really good and made things a lot faster, like 10 times faster.
- 57:21And we didn't have any sort of extension modules that didn't work with PyPy.
- 57:25They all did work with PyPy and it was, it was really, really good.
- 57:28So use that if it works for you.
- 57:30Although PyPy, it's a bit big though.
- 57:32But it's, what it does, it does really well.
- 57:35So on the other hand, making CPython faster, just the core CPython, I think is a fantastic goal.
- 57:40And I think probably the thing I would say is that any interest in Python is good for CircuitPython and MicroPython and the general Python ecosystem.
- 57:50Just because it's people working on Python and trying to make it better.
- 57:53Whether or not, you know, there's something that comes out at the end is kind of secondary.
- 57:59It's that people are interested in hacking on things and having fun and things will come out of it.
- 58:05Part of it, maybe it's not going to be a very, a super fast CPython at the end, although that would be really great.
- 58:10And that's what people are really, really working towards now.
- 58:13But I just think the general interest in Python is the biggest thing that will come to us.
- 58:18Is that, you know, Python will be in the headlines more and people will be talking about how it's faster now and it's interesting and it will change people's perceptions.
- 58:26And then people will learn more about MicroPython and through Python and C.
- 58:29Yeah, we'll start having to deal with all these articles.
- 58:32People are leaving C and Go because it's so slow now.
- 58:35And back on the table.
- 58:37Well, yeah.
- 58:39Python is such an ergonomic language.
- 58:42It's so great.
- 58:43Yeah, it's so lovely.
- 58:44I think actually the performance side is just so, so many layers, right?
- 58:48Like it's slow, except for if you use the SciPy libraries, all of a sudden it's really fast and then like, it's just, it's super interesting.
- 58:55It really depends what you're using it for.
- 58:56And I don't think you should, slow Python shouldn't be, it should be banished to that concept.
- 59:02It should be like, use Python and see if it works for you.
- 59:05Because, and if it doesn't, you know, then use a different language.
- 59:08But that's the same you say with any language.
- 59:10It's like use the language if it's going to work for you.
- 59:12Yeah.
- 59:13And oftentimes it's just, well, you're not using the right part of the Python ecosystem to address that problem.
- 59:18Yeah.
- 59:19Right.
- 59:20Yeah.
- 59:21Scott, do you want to maybe weigh in on that real quick before we wrap it up?
- 59:22We're about out of time.
- 59:23I generally, I delegate to Damian.
- 59:25Damian does a lot of work on this core and makes it really fast.
- 59:28I try not to get sucked into the performance stuff because I'm trying to do the workflow side of things.
- 59:33But I did want to point out for those folks that are coming from CPython and may not have done embedded Python, is that the boards that we run on, but both MicroPython and CircuitPython, we're very much in Moore's law territory still.
- 59:45The first board that I supported is 48 megahertz, but the TNT4 runs at 600 megahertz.
- 59:51So we can get a lot of speed within this domain by paying a few dollars more.
- 59:56That's important to realize is that like the things that we do for speed may not be the things that you would do in CPython.
- 1:00:02Interesting.
- 1:00:03Yeah.
- 1:00:04There's hardly a make the computer faster answer at the CPython level.
- 1:00:08We do kind of have a turbo button if we can just clock the CPU faster.
- 1:00:12Yeah.
- 1:00:13Awesome.
- 1:00:14I thought it had a turbo button.
- 1:00:15I loved it.
- 1:00:16And it was probably just as fast as what we're running MicroPython and CircuitPython on now.
- 1:00:20How interesting.
- 1:00:21Yeah, for sure.
- 1:00:22All right, you guys.
- 1:00:23Well, we could go on and on and on about this.
- 1:00:25Maybe we'll have to do another episode, but I think we're probably out of time.
- 1:00:28So I'm going to ask you a couple of wrap up questions.
- 1:00:31I normally ask the editor and IPI library.
- 1:00:35Maybe we'll go ahead and do that, but I want to throw in one more thing as well.
- 1:00:40So let's do editor first.
- 1:00:42If you're going to write some code that runs on either Circuit or MicroPython devices, what editor do you use?
- 1:00:48Vim.
- 1:00:49I've used Vim since day one, I think.
- 1:00:50Right on.
- 1:00:51Scott?
- 1:00:52I use Sublime Text.
- 1:00:53Cool.
- 1:00:54Very good.
- 1:00:55Very good.
- 1:00:56Notable PyPI package.
- 1:00:57Something out there that's pretty cool.
- 1:00:58I've seen a bunch of things going by in the live chat as we're talking.
- 1:01:01It's very active today.
- 1:01:03So I think HTTP IE is really quite a cool tool for like instead of W get.
- 1:01:10I've 100% moved to HTTP IE.
- 1:01:11I guess it's like curl or W get, but you get like syntax highlighting for your response.
- 1:01:21It's beautiful.
- 1:01:22And it's actually a good tool for when you're like working with MicroPython.
- 1:01:26If MicroPython actually accepts, you know, HTTP.
- 1:01:29It's not just for pretty printing.
- 1:01:31It's good for actual workflow as well.
- 1:01:34Yeah.
- 1:01:35Well, Scott, you got one to recommend?
- 1:01:36For the folks in CPython who are getting into hardware, if you have a Raspberry Pi, Blinka
- 1:01:40is great.
- 1:01:41Blinka.
- 1:01:42Okay.
- 1:01:43As the foundation, you'll want to find a device that you're interested in using and then
- 1:01:45you can use Blinka.
- 1:01:46Yeah.
- 1:01:47I don't know.
- 1:01:48That's a really good one.
- 1:01:49The HTTP is a good one.
- 1:01:50I'll have to take a look at that.
- 1:01:52Yeah.
- 1:01:53I've completely switched on all my servers and even on my desktop to just have that for a
- 1:01:56testy thing.
- 1:01:57It's really, really good.
- 1:01:58Okay.
- 1:01:59Here's the extra third question that normally we don't get.
- 1:02:01So if you're going to work on a project, I have all these ideas of things that I would
- 1:02:04love to create and stuff, but I don't ever know really what the right hardware for it
- 1:02:10is.
- 1:02:11So I guess, Damon, you first, if you're going to work on something and you've got some idea,
- 1:02:14you know, what kind of board would you get?
- 1:02:16Maybe you have to give us a little background, like the scope of the idea or the context, but
- 1:02:20what board would you play with if people are thinking of getting into stuff and playing
- 1:02:23with it and so on?
- 1:02:24Yeah, that's a good question.
- 1:02:25It really depends on the project.
- 1:02:27If you want something like the PI board, we started making and selling that like eight
- 1:02:34years ago.
- 1:02:35That was the first Kickstarter.
- 1:02:36And we still sell a lot of these.
- 1:02:38The original PI board down a little bit of that page.
- 1:02:41Yeah, that one.
- 1:02:42And that's just a really good general purpose workhorse with good IO support.
- 1:02:46And I use it still today to do things.
- 1:02:49And that's really cool.
- 1:02:50If you want high performance Wi-Fi Bluetooth, if you just scroll back up over it, then the
- 1:02:54new PI board D is what you need.
- 1:02:57And that, you know, that has really fast Wi-Fi and really good Bluetooth support.
- 1:03:02the Raspberry pypyco, I think is a really another really good option if you want something that
- 1:03:07has is relatively cheap and has good functionality.
- 1:03:11And this new PI O programable IO stuff that Scott was talking about.
- 1:03:15That's also a really cool option.
- 1:03:17There's a whole lot of stuff out there.
- 1:03:19Yeah, there's a lot of choice.
- 1:03:20And it's all really good choice.
- 1:03:22Exciting.
- 1:03:23Yeah, very exciting.
- 1:03:24And not super expensive, as you all were saying, like you can get them and try them.
- 1:03:27It's not a huge investment.
- 1:03:29Scott, what's your your dream board that you would recommended board you would start with?
- 1:03:33I don't think there's any one board.
- 1:03:35I see some people trying to make this particular board they have do something that it doesn't
- 1:03:41necessarily do very well.
- 1:03:42So what I recommend people is actually go to learn.adafruit.com, which is where Adafruit
- 1:03:48has all of our tutorials and look there, find a project that is close or exactly what you
- 1:03:54want to do.
- 1:03:55And then you'll see all of the stuff that you need to do that.
- 1:03:58That's where I would start, because not only are you picking the hardware that you that you
- 1:04:03could use to do what you want, but you're also getting all the software to do it as well.
- 1:04:06You're definitely getting a head start by starting from an existing project.
- 1:04:10Yeah, that's an interesting perspective.
- 1:04:12Like instead of what board do I want?
- 1:04:14Like what project?
- 1:04:15What thing do I want to create and solve?
- 1:04:16Now what hardware do I need to like facilitate that?
- 1:04:19Yeah.
- 1:04:20And then the other thing you can do is if you go to circuitpython.org/downloads, you actually
- 1:04:24can type different features.
- 1:04:26Like you want to see all the BLE boards or the Wi-Fi boards.
- 1:04:29It will filter out the boards there for you.
- 1:04:32And those are all the boards that circuitpython runs on.
- 1:04:34Very neat.
- 1:04:35Very neat.
- 1:04:36All right, you guys.
- 1:04:37Well, thank you for being here and sharing this.
- 1:04:39It's really cool to see the two projects working more closely together.
- 1:04:42So final call to action.
- 1:04:43People want to get started.
- 1:04:44One from each of you, I guess.
- 1:04:45Like what would you tell people?
- 1:04:47Well, go to micropython.org.
- 1:04:48Go to forum.micropython.org.
- 1:04:50Where our forum is, that's sort of the most active place for discussion.
- 1:04:54And then GitHub micropython/micropython is also where all of the development action is.
- 1:05:00Scott?
- 1:05:01For circuitpython, you can go to circuitpython.org and the /downloads is particularly useful
- 1:05:07if you happen to have a device already in hand.
- 1:05:09That will get you the file for that particular device.
- 1:05:13If you want to hang out with us that are working on circuitpython, we do have an Adafruit
- 1:05:17Discord server.
- 1:05:18Everybody is welcome to join.
- 1:05:19You can go to the URL adafru.it/discord.
- 1:05:23That's the short link for it.
- 1:05:25And that will get you in there.
- 1:05:26You'll see there's a circuitpython dev channel.
- 1:05:28That's where we coordinate all the development.
- 1:05:30And on GitHub, we're github.com/adafruit/circuitpython.
- 1:05:34We're moving more and more to, we have a circuitpython organization as well.
- 1:05:38So maybe at some point we'll do, we'll be github.com/circuitpython/circpython.
- 1:05:42Right on.
- 1:05:43I was also just going to throw out that you do a fair number of live stream Twitch-like
- 1:05:48things.
- 1:05:49Maybe just tell people about that as well if they want to catch you there.
- 1:05:51Yeah.
- 1:05:52So I started live streaming kind of like as the pandemic ramped up as just like something
- 1:05:56I've wanted to do.
- 1:05:57So I started doing it regularly.
- 1:05:58I do it at 2:00 PM Pacific on the Adafruit channels.
- 1:06:01So you can go to youtube.com/adafruit.
- 1:06:03It's called deep dive with Scott.
- 1:06:05There's a playlist there.
- 1:06:07They tend to be about two hours or more and very casual, no editing, but I answer questions
- 1:06:13and show off into the weeds of circuitpython stuff.
- 1:06:17And we've gotten a lot of contributors out of that, which has been great.
- 1:06:20Yeah.
- 1:06:21Fantastic.
- 1:06:22So if you want to hang out on a Friday afternoon, everybody's welcome to do that.
- 1:06:24And we've talked to Damien about joining that at some point as well.
- 1:06:27Cool.
- 1:06:28Well, I'll look forward to seeing you both over there as well.
- 1:06:30So thanks for being on the show.
- 1:06:31Thank you.
- 1:06:32Thanks, Michael.
- 1:06:33Yeah, you bet.
- 1:06:34This has been another episode of Talk Python To Me.
- 1:06:37Our guests on this episode were Damien George and Scott Shawcroft.
- 1:06:40It's been brought to you by Sentry and Linode and the transcripts are sponsored by Assembly
- 1:06:45AI.
- 1:06:46Take some stress out of your life.
- 1:06:47Get notified immediately about errors in your web applications with Sentry.
- 1:06:51Just visit talkpython.fm/sentry and get started for free and use the promo code talkpython2021
- 1:06:59when you sign up.
- 1:07:01Simplify your infrastructure and cut your cloud bills in half with Linode's Linux virtual
- 1:07:05machines.
- 1:07:06Develop, deploy, and scale your modern applications faster and easier.
- 1:07:09Visit talkpython.fm/linode and click the create free account button to get started.
- 1:07:14Transcripts for this and all of our episodes are brought to you by Assembly AI.
- 1:07:18Do you need a great automatic speech to text API?
- 1:07:21Get human level accuracy in just a few lines of code.
- 1:07:23Visit talkpython.fm/AssemblyAI.
- 1:07:26Want to level up your Python?
- 1:07:28We have one of the largest catalogs of Python video courses over at Talk Python.
- 1:07:31Our content ranges from true beginners to deeply advanced topics like memory and async.
- 1:07:36And best of all, there's not a subscription in sight.
- 1:07:39Check it out for yourself at training.talkpython.fm.
- 1:07:42Be sure to subscribe to the show, open your favorite podcast app, and search for Python.
- 1:07:47We should be right at the top.
- 1:07:48You can also find the iTunes feed at /itunes, the Google Play feed at /play, and the direct
- 1:07:54RSS feed at /rss on talkpython.fm.
- 1:07:57We're live streaming most of our recordings these days.
- 1:08:01If you want to be part of the show and have your comments featured on the air, be sure
- 1:08:05to subscribe to our YouTube channel at talkpython.fm/youtube.
- 1:08:09This is your host, Michael Kennedy.
- 1:08:11Thanks so much for listening.
- 1:08:12I really appreciate it.
- 1:08:13Now get out there and write some Python code.
- 1:08:15I'll see you next time.
- 1:08:16I'll see you next time.
- 1:08:16Bye.
- 1:08:17Bye.
- 1:08:18Bye.
- 1:08:19Bye.
- 1:08:20Bye.
- 1:08:21Bye.
- 1:08:22Bye.
- 1:08:23Bye.
- 1:08:24Bye.
- 1:08:25Bye.
- 1:08:26Bye.
- 1:08:27Bye.
- 1:08:28Bye.
- 1:08:29Bye.
- 1:08:30Bye.
- 1:08:31Bye.
- 1:08:32Bye.
- 1:08:33Bye.
- 1:08:33you
- 1:08:33you
- 1:08:34Thank you.
- 1:08:35Thank you.
- 1:08:35Thank you.