Brought to you by Michael and Brian - take a Talk Python course or get Brian's pytest book


Transcript #176: How python implements super long integers

Return to episode page view on github
Recorded on Wednesday, Apr 1, 2020.

00:00 Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.

00:05 This is episode 176, recorded April 1st, 2020.

00:10 April Fool's.

00:11 So, I'm Brian Okken.

00:13 I'm Michael Kennedy.

00:14 And this episode is brought to you by DigitalOcean.

00:16 We'll talk more about them later.

00:19 But, yeah, let's just catch up a little bit.

00:22 What's going on?

00:23 Oh, you know, this is one of the few bits of human interaction outside of my house that I get.

00:30 It's to talk to you here on Skype video, right?

00:32 Like, it's a weird time, isn't it?

00:34 It's totally weird.

00:35 We normally don't record video, but we do see each other.

00:39 And we've noticed as we contacted us or connected today that both of us have new haircuts, but they're homegrown haircuts.

00:46 I never cut my own hair.

00:49 And it was getting bigger and bigger.

00:50 And my hair doesn't get long.

00:52 It just gets big and poofy.

00:54 And it's more like a Q-tip on top of my head.

00:56 And eventually, I just break down.

00:58 Like, I can't do this.

00:59 So, at first, I looked at my daughter who's 19.

01:01 I'm like, here's a shaver.

01:02 You got to cut my hair.

01:04 And she's like, no, no.

01:05 And so, she did an okay job.

01:06 And that was really good.

01:08 And then I decided to go back.

01:09 And, like, it was still quite a bit, actually, longer than I wanted.

01:11 So, I gave it a second haircutting as well.

01:15 Yeah.

01:15 And, you know, honestly, it's about as good as the haircuts I pay for.

01:19 So, I'm feeling like this might be a trend that I was forced into.

01:21 And you're looking good yourself.

01:23 Yeah.

01:24 So, I normally have, like, a short goatee thing that I keep.

01:28 And I just have, when I bought the trimmer for it, I just only needed one guard because,

01:32 I mean, I didn't think ahead.

01:34 And I just, like, I don't know where all the rest of the guards were.

01:38 So, I only have that, like, little short guard for the trimmer.

01:42 And my wife was willing to cut my hair.

01:45 But it's a little shorter than I was expecting.

01:47 But I think it's all right.

01:48 I don't have to worry about it anymore.

01:50 My kids, like, say it's like a peach.

01:52 So, they come by and rub my head all the time.

01:55 It looks good.

01:55 And that's the weird world we find ourselves in.

01:57 You know, I'm here drinking coffee out of this Pittsburgh mug.

02:00 But there will be no Pittsburgh, right?

02:02 PyCon is now officially canceled.

02:03 Yeah.

02:04 That's a bummer.

02:05 This might be the first recording since it was actually fully, fully canceled.

02:09 At least the first time we spoke about it, possibly.

02:11 We might have mentioned it last time.

02:12 But there's certainly a tightening up on getting together for conferences and that kind of thing.

02:18 And, you know, we spoke a little bit about what's going to stick.

02:21 These changes that we have to have that are going to stick.

02:23 Like, a lot of meetings could just be emails.

02:25 Or they could be remote or whatever, right?

02:28 And I wonder what that's going to do to the conference space.

02:30 Yeah.

02:31 I wonder, too.

02:32 One of the reactions I heard from somebody was, even if it was to move towards a virtual,

02:37 which they were talking about that a little bit, maybe doing a virtual conference.

02:42 But that wasn't the thing.

02:43 It's essentially canceled.

02:45 Although some people are sending in videos, they're going to have some people be able to

02:49 send in their presentations as videos.

02:51 So that's neat.

02:52 But it's the meeting people.

02:53 We interact with people online all year long.

02:56 And it's one chance to get together.

02:58 So at least with PyCon, I don't think that'll go away.

03:02 No, I don't think so.

03:02 For me, it's not about the talks.

03:04 I go to talks and they're interesting.

03:06 But it's about the stuff that happens in between it.

03:09 It's about hanging out with you, hanging out with people from other places I don't normally

03:14 see, making those connections, and just stumbling onto things that are like, oh, I had no idea

03:19 that this was happening.

03:20 Let's talk about that.

03:21 That's the value.

03:22 And that's really tough to replace.

03:23 Yeah, it really is tough to replace.

03:25 Maybe more video chats will help.

03:27 Absolutely.

03:27 All right.

03:29 Well, I guess everyone be safe out there.

03:30 Yeah.

03:31 And follow our lead.

03:32 Stay home, even if you got to cut your own hair.

03:34 Well, let's move on to some topics.

03:37 So first off, I was hoping to talk about PyProject.toml.

03:41 I think we've, I'm sure we've covered it before.

03:43 But the Brett Cannon is, is he still part of the core or did he get voted out?

03:49 I think he's still part of the core at Honchos.

03:51 I think he's on the steering council.

03:52 Yeah.

03:53 Yeah.

03:53 He wrote an article just released recently called, What the Heck is PyProject.toml?

03:58 And one of the reasons why he wrote it, and I think this is an interesting side effect,

04:04 is so if you're just, if you're just joining us, the PyProject.toml came out of the efforts

04:10 with PEP 517 and 518 to define what the file looks like.

04:15 And it kind of defines what tools are needed to build a project and, and how to build it.

04:21 And that used to be mostly just setup tools, but now there's lots of other tools like Flit

04:27 and Poetry, and you can make your own if you want to.

04:31 But these are, this file, one of the side effects is people started adding other, their tool

04:38 configuration to this file, such as like coverage and talks.

04:42 Now you can, you can put the, those configurations into PyProject.toml for those tools, even,

04:50 even though it has nothing to do with building and it just saves you from having an extra file,

04:55 but even though those tools have their own configuration files.

04:57 And then Black came around and Black uses, only has a few configurations available.

05:04 So instead of creating their own configuration file, Black uses the PyProject.toml for looking

05:10 up configuration if you want to configure like line length or something.

05:13 And so there's, there's been projects that have added PyProject.toml files for the reason

05:19 because they were trying to, they're using Black also.

05:22 And now their, their builds don't work.

05:24 And the reason is if there's a PyProject.toml, even if you're using setup tools, pip will,

05:30 pip will look for the build stuff around that within the file.

05:35 So Brett is, has gone and added, showed the, the few lines of code you need to add to the

05:42 toml file to specify how to build with setup tools.

05:45 That's the main contribution for this, but it's also, I think that people ought to, ought to

05:49 go read the article because it's a good, a good summary of where we're at right now.

05:53 Yeah.

05:53 The PyProject.toml is great.

05:55 And it's super cool that you can specify things like here's how you can say, build the package,

06:01 right?

06:01 It requires a wheel and whatnot.

06:03 Yeah.

06:04 It's, it's cool.

06:05 I really like it.

06:06 I honestly need to start working with it.

06:09 I'm still on the requirements.txt side of the fence, just waiting for things to, you know,

06:15 shake out, but it certainly seems like there's a lot of energy here.

06:18 Yeah, definitely.

06:19 Yeah.

06:19 So definitely good pick there.

06:20 You know, sometimes we talk about awesome things on Python bytes, right?

06:24 Yeah.

06:24 And we've even talked about awesome lists, which are lists organizing various other things,

06:31 projects, websites, tools, whatever around something.

06:34 But last time in passing, we mentioned that there was a cool article by Jack McHugh, where

06:40 he blogged about the awesome Python bytes, awesome list.

06:43 Yeah.

06:44 That was cool, right?

06:45 Yeah.

06:45 So now Jack has made this a proper GitHub repository where it has a clear way to contribute to it.

06:53 You can do PRs and all sorts of stuff.

06:56 And he said he'll be adding personally to the repo whenever he hears about awesome things like

07:01 this.

07:01 Maybe he'll add his own list to it, which would be very meta, right?

07:04 It would just link back to itself.

07:06 No, just kidding.

07:06 But that's really awesome.

07:07 And there's already five PRs from listeners accepted on this list.

07:12 Oh, wow.

07:12 That's great.

07:13 Isn't that cool?

07:14 People seem to be liking it.

07:15 After we announced it, then we had other people saying, and I saw some commentary about there

07:20 was some missing that he forgot about.

07:22 Yeah.

07:22 Well, it's just the stuff that really stood out to Jack in the beginning, right?

07:26 So if you want to go back and kind of look through what some people thought of a year and a half

07:31 ago that we talked about that was awesome, you can go there.

07:33 And if you look at it, it comes with graphics.

07:36 Like all good things that present things, if you can have graphics, guess what?

07:40 It's like a thousand words, isn't it?

07:41 Oh, yeah.

07:43 Isn't that cool?

07:43 This is great.

07:44 Yeah.

07:45 It's really, really polished.

07:46 And you can just flip through and like, we talked about D type, the visualization for

07:52 Panda's data frames.

07:53 And, you know, there's like some nice examples and pictures there.

07:56 Really, really good stuff.

07:58 So I think it's a great way to explore some of the stuff that we talk about.

08:01 A couple of fun projects I saw on there that I just remembered.

08:04 Oh, yeah, we did talk about that.

08:05 It was cool.

08:06 It was great expectations for validating, documenting, and profiling data.

08:11 Panda's vet, which is a flake eight, a linter for opinionated pandas code.

08:16 Geoalchemy, which is like geospatial databases on top of SQLAlchemy.

08:20 And Vue.py, which provides in-browser Python runtimes interacting with Vue.js.

08:27 So just, you know, all sorts of cool stuff there.

08:29 And I guess related to this, although not technically anything to do with that, is we

08:35 have a super cool search over at Python by set of M slash search.

08:38 And it's really fast.

08:40 It even searches our spoken words.

08:42 So if you want to just find something that maybe we talked about a long time ago or see

08:47 if it's covered, throw it in there and it'll pop up.

08:49 That's really neat.

08:50 And I love this because I'm like flipping through this going, oh, I want to go back and

08:54 check that out again.

08:55 Exactly.

08:57 Like that was like a year and a half and we only spent like, you know, half an hour

08:59 playing with it before we talked about it.

09:01 Then maybe we didn't use it again.

09:02 But yeah, it was cool.

09:03 So I legitimately enjoyed going through the list here and I thought listeners might as well

09:07 if they heard it before or even if they didn't.

09:09 Yeah.

09:10 Yeah.

09:10 That's awesome.

09:11 Yeah.

09:11 Well, I guess you were going to continue a theme a little bit with your, from the pyproject.toml

09:17 onward, huh?

09:17 I've been playing with a project for a while off and on associated with testing code called

09:24 the cards project.

09:25 And it's a little to-do app thing.

09:28 It's just a little sample thing to mostly to play with all of the stuff around Python and

09:33 distribution and testing and, and all that.

09:36 And, somebody, oh gosh, it was months ago and I should have their name here.

09:42 But one of the, somebody else contributed a pull request to add a GitHub actions.

09:47 So GitHub actions are a way to, you know, for, you can use that for like CI, CD workflows

09:54 with Python project with all, all sorts of stuff, but with, especially with Python projects,

09:59 because you know that the building pipeline is kind of short, with, with Python, it's

10:05 not as complicated as other things.

10:06 So often you don't really, it's, it might be overkill to use another CI system.

10:11 and so GitHub actions are really pretty cool for that.

10:15 And so I incorporated that and then was looking into the last step was how do I publish to

10:22 the PyPI?

10:22 I'd really like to add that.

10:24 So there's a, I was looking it up and the PyPI, the Python packaging authority actually

10:29 has a article written called publishing pack, publishing packets, distribution release releases

10:36 using GitHub actions with CI, CD workflows.

10:40 And so this was like, I'm following through this.

10:42 I'm actually ran into some hiccups, but I wanted to cover it anyway.

10:45 My promise is that by the time this goes live, the cards project will actually be complete

10:51 because it's, it's almost there.

10:52 There's a few hiccups I've ran into.

10:54 PyPI requires you to have an email associated with package, which is kind of annoying because,

11:01 split and pip don't anymore, but PyPI still does.

11:06 So I had to do that.

11:07 And there's a few, a few other hiccups.

11:09 I don't know if I'll write it.

11:10 If there's just these, I'll probably just fix them and have it ready for people to look at.

11:14 But, if it's too many more, I'll have to write a new blog post and I'll associate that

11:20 with this as well.

11:20 Yeah, this looks great.

11:21 And I had no idea about the GitHub secrets.

11:24 So one of the challenges is you want to have your personal PyPI account where you are the maintainer admin of that package on pypi.org.

11:34 You might not want to contribute that into the source code, especially for an open source project, right?

11:39 Yeah, probably a bad idea.

11:41 Yeah, that's going to result in some bad things happening there.

11:43 Eventually it talks about how to use the secrets settings in GitHub to store those there and then how to like pull those out as replacements in your GitHub actions, which I had never done.

11:55 That's pretty cool.

11:55 Yeah, and the workflow that they're suggesting, which is, I think, a great idea, is to go ahead and have all, every pull request or merge to your, some master branch or to anywhere, any branch, go through the entire thing and try to publish to the test pypi server.

12:13 And only ones where you change the tag, which is where you would change, you'd change a tag if you change your version number.

12:20 That's when it would push to a pypi, the real one.

12:24 But to have that workflow even going through the test pypi every time you push something, I think that's a great idea.

12:31 Yeah, it is.

12:31 But somehow you've got to change the version number or it's not going to let you publish even to test, right?

12:35 Yeah.

12:36 So I'm not sure.

12:37 I still am figuring out how to get around that.

12:39 So we'll see.

12:40 Yeah.

12:40 Cool.

12:40 One of the things I love, I love really great tutorials.

12:43 The internet, I think, is working because of the great tutorials around.

12:47 And one of the groups that have put out some awesome tutorials is DigitalOcean.

12:53 So DigitalOcean is sponsoring this episode.

12:55 And one of the things that they're offering, of course, is they offer a way to get started with, they offer Kubernetes clusters.

13:03 And you can do that with DigitalOcean.

13:05 But to get started with hosting and running Linux servers with Kubernetes clusters, that can be a little tricky.

13:11 And that's why we want to highlight that DigitalOcean has launched their new support center.

13:16 And this makes it easier to find answers to your questions, help you get up to speed, get what you need.

13:22 And you can search across product documentation and community tutorials and forums all in one place.

13:29 And especially with something tricky like a Kubernetes cluster, really, even if you're new at any of this, their support center is awesome.

13:36 Got great tutorials.

13:37 So visit pythonbytes.fm/doc support to see their tutorials.

13:43 And of course, use pythonbytes.fm/DigitalOcean for $100 credit for new users.

13:49 Yeah, absolutely.

13:49 Their tutorials are so good that you can even select different operating systems and different versions so that the steps exactly line up.

13:58 If you're on, say, Ubuntu 16, you don't have to try to patch that back.

14:03 The tutorial steps would be different, which is, that's taken to the next level.

14:06 Very good stuff.

14:07 I've heard some from somebody once before where they were actually using a different host and using DigitalOcean tutorials to help them set it up.

14:14 And then they finally realized, why am I giving money to somebody else?

14:17 Let's use DigitalOcean because they helped me out.

14:20 That's where our infrastructure is.

14:22 Very good.

14:22 Now, this next one, Brian, this one is best seen through pictures.

14:26 So make sure you open this up and we talk through it.

14:29 So like I said, all good presentations, especially stuff that's graphical, has pictures, people.

14:35 This is amazing.

14:35 So this thing that I want to talk about is called rich.

14:38 Rich text for terminals.

14:40 So we've talked a lot about how it's great to have GUIs and web apps and stuff like that that's very visual for the presentations, which are still true.

14:49 But a lot of times you just want something in a little terminal app, command CLI app.

14:54 And it would be nice if it wasn't just all one plain color or just, you know, all text left aligned.

15:00 So there's this cool project called rich.

15:03 And rich lets you have up to 16.7 million colors for your terminal colors, not just like eight or whatever it is, you know, red and light red, like 16.8 million colors.

15:16 It supports bold, dim, italics, underlined, strikethrough, and even, please don't use it, the blink tag.

15:23 You can put the blink tag out there.

15:25 You can have text that's left aligned, centered, right aligned, justified, supports like Chinese and Korean, has emojis.

15:34 Like you can put colon, apple, colon, and an apple shows up.

15:38 You can, as part of a string, put little escapes.

15:42 So you can say this word is bold magenta.

15:45 And then here's the rest of the words and just print that thing out.

15:47 So you have like inline styling.

15:48 Tables.

15:49 You have beautiful tables like in the terminal.

15:53 Those are really nice.

15:54 Those are really nice.

15:56 Syntax highlighting for code.

15:57 So you can print out Python code with line numbers and it'll highlight it.

16:00 And it even has a markdown support.

16:03 So you could write markdown and it renders it as its own version of rich text.

16:07 Not quite HTML or something like that, but it has, you know, bulleted lists and like titles and whatnot.

16:13 Even as progress bars and logger support and all kinds of stuff.

16:16 Isn't that cool?

16:17 Yeah.

16:17 The logger handling is actually pretty great.

16:20 Yeah.

16:20 So if you're working on a terminal app and you're like, we're just going to keep it this way, but I want it to look nicer.

16:26 I want it to look a little more professional.

16:27 This is like kind of your all in one, do a bunch of cool stuff here.

16:31 You can even have multiple progress bars, all updating in parallel on the screen.

16:36 So if you've got a bunch of downloads, you can indicate them all happening or something like that.

16:40 A bunch of jobs running.

16:41 Sweet.

16:41 So yeah, this is a cool project.

16:43 Might have to add this to cards.

16:45 That would be cool.

16:45 That would be awesome.

16:46 Yeah, it definitely would.

16:47 It even has all of that support for Windows.

16:52 If you use the new Windows console or terminal, I guess is the word that they're now using because console, I guess, is the old school thing.

16:58 And Microsoft's like, no, no, we all have terminals now.

17:00 And you can go get that from the, you probably don't have that on Windows.

17:04 It's in preview, but you can get it on the Windows store for free.

17:07 And I link to that as well.

17:09 So if you're on Windows and you want a better terminal in general that supports this kind of stuff, check that out too.

17:14 Hmm.

17:14 Interesting.

17:15 Second, do you know if that'll roll into the normal, just all releases of Windows at some point?

17:20 I would hope so.

17:21 Maybe.

17:21 It's still in beta.

17:22 I guess we'll have to see, but it would be nice, right?

17:25 It'd be one step closer to parity across all these platforms, which, you know, it's always good.

17:30 Yeah.

17:30 I just use the bash terminal for bash for or get for Windows comes with a bash terminal.

17:35 Right.

17:36 Nice.

17:37 Speaking of Windows, I guess it's any operating system, but I'm actually kind of surprised.

17:42 This has been on our to-do list for a long time.

17:44 A library called psutil.

17:46 It's a cross-platform library for process and system monitoring in Python.

17:51 And I'm actually surprised that we haven't really covered it.

17:54 We must have covered it in passing a couple of times.

17:56 But I wanted to highlight it because it is an amazing little tool.

18:00 It's not something I really like love when I have to use it.

18:04 But things like there's time zone control and multiple computers or services running on a different machine with Windows.

18:12 Like I said, you can use it with it.

18:14 It's a cross-platform thing.

18:16 But you can use this to grab CPU utilization, memory utilization, disk usage, network, what ports are being used.

18:24 And you can even see all of this information based on which process.

18:28 So you can get like a per process list of CPU usage and everything within that.

18:35 And then around processes, you can suspend and kill and signal different processes.

18:41 So if you're one of the things that we use this for is monitoring our build servers.

18:46 I know there's other ways to do it, but this is a pretty easy way to go over to another server and grab the CPU usage and memory usage.

18:55 So we can keep track of all of our, make sure all of our build servers are working and not overloaded.

19:01 So we use this.

19:03 It's a pretty cool little tool.

19:04 Yeah, this looks really great.

19:05 I think we also talked about it last week briefly when we covered pytest Monitor.

19:11 And that was built on top of psutil amongst other things.

19:14 We didn't cover psutil, but like it's that kind of tools that this enables, right?

19:19 Yeah, pytest Monitor used that also.

19:21 I'm like, man, I think we covered this recently.

19:23 But yeah, it was last week we covered that.

19:26 By itself, it's still a really great thing to use right itself.

19:29 And the readme is huge, but it shows you a lot of different examples for how to use it.

19:35 Yeah, it looks super useful.

19:37 If you're going to do any automation and sort of admin sort of work, it looks great.

19:42 One of the great things that I love is the cross-platform part because this sort of stuff you can do on,

19:48 I mean, you can do directly with Windows and with Unix, but, you know, it's different on everything else, on everything.

19:54 And so having a cross, I'm pretty impressed that it can even exist as a cross-platform thing, but it can.

19:59 Yeah, no kidding.

20:00 Apparently it can, and it's awesome.

20:02 Definitely a good one.

20:03 So let me ask you this question.

20:05 If I'm going to store some numbers, let's say up to 100,000, how big of an integer do I need to make in Python?

20:13 I don't have to make an integer.

20:14 They're just there.

20:16 They're just there.

20:17 It's beautiful, right?

20:18 But I know that you've done a lot of C and C++, and I have as well back in the day, and you used to have to really think about that, right?

20:25 Like if you saw a negative 32,000 for a number and you thought you were adding to it, you're like, oh, it was a short and it overflowed.

20:33 Well, I guess it's maybe it should be a U short, unsigned short.

20:36 It could hold up to 65,000, right?

20:38 Like this is something you always had to think about.

20:40 And in Python, you don't.

20:42 And how that happens is pretty interesting.

20:45 I didn't really know the internals.

20:47 I kind of guessed maybe something like what's happening, what's happening, but I didn't know.

20:52 And so there's a cool article by Arpiz Bayani, and he wrote something called How Python Implements Superlong Integers.

21:00 So, for example, if you tried to take two and raise it to the power of 20,000 in C, you would get infinity.

21:07 Right, because it's, well, it's bigger than we can hold it, so it must be infinity as far as we're concerned.

21:13 But in Python, it's fine.

21:15 It just gives you a 6,021-digit integer, and you don't have to declare, like, I'm working with really big numbers or anything like that.

21:22 And so Python is pretty cool in how it's transparent with these, right?

21:26 Yeah.

21:26 Yeah.

21:27 So this article digs into the CPython source code.

21:33 It talks about the algorithms and the data structures that make this happen.

21:37 So basically, the numbers in Python are represented as what's called a pyvar object.

21:44 So pyobject, that's the core type of things in Python.

21:48 But this is a variable length one, right?

21:51 And so there's a couple of different types that are like this.

21:54 We've got lists.

21:56 We've got tuples.

21:56 But we also have numbers.

21:58 And that indicates that they can be of different size, and they can basically grow as they need to.

22:04 Right?

22:05 So Python's numbers ultimately are represented by this thing called a long object.

22:10 And that has a pyobject base.

22:12 But then it also has a size and a digit.

22:14 And these digits are, I think they're four or eight bytes long.

22:20 I can't remember.

22:21 It doesn't say here.

22:22 It's a macro that would expand at four or eight, something like that.

22:25 But basically, it uses a list of digits.

22:28 And it, you know, initially, it just uses one of those.

22:31 But then when it gets full, it adds another and another and another.

22:35 What's interesting is they're base 230, not 10, not 16, 230.

22:40 That's weird.

22:41 Okay.

22:41 Yeah, because apparently it can most efficiently use that's exactly that space.

22:46 Okay.

22:47 Of its four bytes or whatever as individual elements in a base.

22:51 So it's pretty interesting.

22:52 Like there's this ginormous number.

22:54 And if you were trying to represent it in base 230, it's 100.

22:57 I'm not going to read it off because it's really, really long.

23:00 But it's pretty interesting how it uses this.

23:02 But then when you get into operations, right, if I'm going to add two numbers and they're

23:06 base 230, like what algorithm do you do?

23:09 It's not like base 10 where you normally do the thing or division or something.

23:14 So that's also interesting to think about.

23:16 If you look at arithmetic, it's pretty straightforward.

23:18 You just add within the digits.

23:20 And if you overflow 230, you do a carryover like you learned in elementary school.

23:24 Subtraction is like you do the borrow.

23:26 So it's like reverse.

23:27 But then multiplication, in order to keep things efficient, uses an algorithm called the

23:32 Karastabu algorithm, which is an interesting way to multiply two in-digit numbers in different

23:42 bases and stuff.

23:43 And yeah, so it's if you've ever wondered how come you don't have to worry about numbers

23:49 overflowing in Python.

23:50 Here's a cool look inside that at the CPython source code and some of the algorithms.

23:54 That's amazing.

23:55 Yeah.

23:56 Actually, that's pretty cool.

23:57 It is pretty cool.

23:58 I'm so glad I don't have to worry about it, right?

23:59 It's just digits happens.

24:00 Yeah.

24:01 One of the definite benefits of Python is this notion of developer time is way more valuable

24:06 than computer time.

24:08 So let's figure all this stuff out for everybody else.

24:11 And then we can stop thinking about it so much.

24:13 Yeah, for sure.

24:14 I had a project many years ago where I had to work with an FPGA and the clock system was

24:20 such that the timing had to set the current time, had to divide that out for a multi-radix

24:28 number.

24:29 So it wasn't like base 10 or base 230.

24:32 It was each digit had its own base.

24:34 Oh my goodness.

24:35 That's crazy.

24:37 It was kind of a beast.

24:39 It was cool.

24:39 A cool algorithm, but it was a fun thing.

24:43 Yeah.

24:43 Yeah.

24:43 Love this sort of stuff.

24:44 Yeah.

24:44 This is really cool.

24:45 A cool glimpse behind the curtain.

24:47 A little bit of the red pill.

24:48 Go down inside, see what's happening.

24:51 One final comment here is there's some funny little tricks you can play on people to ask.

24:57 You can like create the number 10 and then create the number 10 somewhere else and ask

25:00 if those are the same number, like with the word is, it's true for small numbers, but it's

25:06 false for large numbers.

25:06 And that's because Python pre-allocates the numbers negative five to 256.

25:11 Oh wow.

25:12 Okay.

25:13 When you have a hundred in your program, it's the same hundred everywhere.

25:16 But if you have 1,226,411, that was made on the spot.

25:22 Cause these are pointers.

25:23 These are not just like four bytes on the stack.

25:25 These are getting allocated in complicated ways each time.

25:28 And so they said, look, negative five to 256.

25:31 We use these all the time.

25:32 Let's just make them when Python starts.

25:34 Why minus five?

25:35 Well, because who uses minus six?

25:37 Come on.

25:38 I don't know.

25:38 I have no idea.

25:40 I can see minus one and zero to 256.

25:43 But beyond that, I don't really know what they must have some reason.

25:46 Yeah.

25:47 I don't know why.

25:47 They probably started with negative one.

25:49 Somebody said, well, let's do minus two also.

25:51 Oh, let's go hog wild and go all the way down to minus five.

25:55 Exactly.

25:56 Exactly.

25:57 Anyway.

25:57 Hey, that's our six.

25:59 You got anything, any news for us or any extras?

26:02 I have two really quick things.

26:04 You know how Microsoft bought GitHub?

26:06 That was kind of interesting news a while ago.

26:08 And actually people were contemplating the effects that would have on open source and all.

26:12 Yeah.

26:12 Well, NPM, the pip equivalent of JavaScript, is now was acquired by GitHub as well.

26:19 So just interesting moving and shaking over there behind the scenes.

26:23 That's really interesting.

26:24 Unlike PyPA and PIP, NPM was like a commercial venture or something to that effect to try to

26:31 bring that order to the JavaScript side.

26:33 And now, so since it was commercial, it's been acquired.

26:35 So NPM is the JavaScript thing?

26:37 NPM is how JavaScript spells PIP.

26:39 Yeah.

26:42 Okay.

26:45 Okay.

26:46 Quick other one is we're going to try to set up a YouTube channel where people can see both

26:53 of us talking, the silly stuff that we do in a fairly uncut, unedited way.

26:58 But we're going to try to put a video for each topic.

27:01 So we just talked about the Python number thing.

27:03 Like just a single video on that.

27:05 It'll be easy to share with friends.

27:06 It'll be something we put up there.

27:08 So we'll have more details with you soon on the YouTube channel.

27:11 But I'm looking forward to it.

27:12 I think people, it'll give people a new look.

27:14 I think it'll be fun.

27:15 Yeah.

27:15 And then people will be able to recognize our faces when we are not walking around because

27:20 everybody should stay home.

27:21 Exactly.

27:22 Assuming that we continue to just give ourselves haircuts.

27:24 So we look the same.

27:25 Yeah.

27:28 Yeah.

27:28 All right.

27:29 Anything you want to share with folks?

27:30 Nope.

27:31 Nope.

27:32 Just working from home.

27:33 All right.

27:33 Well, I had this joke about C and like numbers overflowing and like, oh, why is it negative

27:38 32,000?

27:40 Oh, because it's 37,000 positive or something like that.

27:43 Right.

27:44 Well, here's another one.

27:45 And this one is just to kind of make you feel good about yourself as a Python developer.

27:49 Right.

27:49 Yeah.

27:50 So this one's visual as a lot of them seem to be lately, but I'll go ahead and we'll do

27:54 our best to describe it.

27:56 Right.

27:57 I'm going to let you be the developer.

27:59 So you do the first three.

28:00 You got to give a little description though.

28:01 Okay.

28:01 So the dude's 830 in the morning.

28:04 I'm staring at the screen and I comment stupid bug.

28:09 And then seven hours later and this guy apparently grows facial hair really fast because he's

28:15 already got stubble at seven, seven hours.

28:18 Oh, it must be Linux.

28:20 And then the next day his face is red and he's even got more hair and he says, JavaScript's

28:26 broken.

28:27 Okay.

28:28 Oh yeah.

28:28 Bob comes in.

28:29 Our other guy comes in and looks at his, oh, hey Bob.

28:32 It looks like you forgot a semicolon.

28:34 Ah, fix.

28:35 Oh yeah.

28:38 Oh man.

28:39 Yeah.

28:39 So that'll be in the show notes.

28:41 You could check out the little comic.

28:42 It's fun.

28:42 It's by Eric Burke.

28:44 Nice one.

28:45 Yeah.

28:45 Don't miss semicolons.

28:47 No.

28:47 Oh, there's a lot of things I don't miss.

28:49 Although I'm doing a lot more C now or C++.

28:53 I got to do it again.

28:54 Well, it just makes you appreciate when you get to do Python.

28:56 Yeah, it sure does.

28:58 So, and appreciate my time with you because this is so special.

29:01 Absolutely.

29:02 Thank you.

29:02 It's great to get together and chat about this and share with everyone.

29:05 Thanks.

29:06 Thank you.

29:06 Yep.

29:06 Bye.

29:07 Bye.

29:07 Bye.

29:07 Thank you for listening to Python Bytes.

29:09 Follow the show on Twitter at Python Bytes.

29:11 That's Python Bytes as in B-Y-T-E-S.

29:14 And get the full show notes at Python Bytes.fm.

29:17 If you have a news item you want featured, just visit Python Bytes.fm and send it our way.

29:22 We're always on the lookout for sharing something cool.

29:24 This is Brian Okken and on behalf of myself and Michael Kennedy, thank you for listening and

29:29 sharing this podcast with your friends and colleagues.

Back to show page