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