|
28 | 28 |
|
29 | 29 | 00:01:11 It really helps support the show. |
30 | 30 |
|
31 | | -00:01:14 Jason, welcome to Talk Python and me. |
| 31 | +00:01:14 Jason, welcome to Talk Python to me. |
32 | 32 |
|
33 | 33 | 00:01:16 Thank you for having me. |
34 | 34 |
|
|
60 | 60 |
|
61 | 61 | 00:02:05 Oh, so went from 4.0 straight A student, college level reading in high school to failing pre-game material, two extra years to climb back up where I was academically a bit longer after that for other things. |
62 | 62 |
|
63 | | -00:02:19 But somewhere along the way, I discovered that I had a natural inclination towards an attack for coding and got into that because I wanted to make games. |
| 63 | +00:02:19 But somewhere along the way, I discovered that I had a natural inclination towards an enact for coding and got into that because I wanted to make games. |
64 | 64 |
|
65 | 65 | 00:02:28 I wanted to make educational games. |
66 | 66 |
|
|
70 | 70 |
|
71 | 71 | 00:02:31 So I learned how to code. |
72 | 72 |
|
73 | | -00:02:33 And so I taught myself VB.net and then felt very constrained by the.net ecosystem and broke out into Python. |
| 73 | +00:02:33 And so I taught myself VB.net and then felt very constrained by the .net ecosystem and broke out into Python. |
74 | 74 |
|
75 | 75 | 00:02:42 found my home, stayed put until I wound up going to a bunch of other languages. |
76 | 76 |
|
77 | 77 | 00:02:47 I used Flash for quite some time. |
78 | 78 |
|
79 | 79 | 00:02:49 I've used C++. |
80 | 80 |
|
81 | | -00:02:50 I muck about in whatever Sandy, but Python is definitely near to dear to my heart. |
| 81 | +00:02:50 I muck about in whatever handy, but Python is definitely near to dear to my heart. |
82 | 82 |
|
83 | 83 | 00:02:55 Yeah, absolutely. |
84 | 84 |
|
|
132 | 132 |
|
133 | 133 | 00:04:06 And then you go all the way to the ever extreme and it's something like super complicated and I'll understand any of it. |
134 | 134 |
|
135 | | -00:04:10 And nobody sat in Brett and wrote down, here's how you structure a multi-Python project in a way that's going to, at least when I started, that wasn't documented anywhere, like no one had ever written it down. |
| 135 | +00:04:10 And nobody sat and wrote down, here's how you structure a multi-Python project in a way that's going to, at least when I started, that wasn't documented anywhere, like no one had ever written it down. |
136 | 136 |
|
137 | 137 | 00:04:20 So it was just like, what do I do now? |
138 | 138 |
|
|
156 | 156 |
|
157 | 157 | 00:04:52 Oh yeah, exactly. |
158 | 158 |
|
159 | | -00:04:54 It's it's the example of given is that there's two types of books slash articles slash tutorial out there. |
| 159 | +00:04:54 It's it's the example of given is that there's two types of books/articles/tutorial out there. |
160 | 160 |
|
161 | 161 | 00:04:59 There's here's basics of variables, boys and girls. |
162 | 162 |
|
|
250 | 250 |
|
251 | 251 | 00:08:22 It's like, well, it's interesting, but it's just a bit early. |
252 | 252 |
|
253 | | -00:08:26 And the early adopters have a lot of egg they're still trying to wash off their face in the last six pads. |
| 253 | +00:08:26 And the early adopters have a lot of egg they're still trying to wash off their face in the last six fads. |
254 | 254 |
|
255 | 255 | 00:08:30 So it's like, let's see what happens. |
256 | 256 |
|
|
378 | 378 |
|
379 | 379 | 00:12:10 You look into it, it's like, that looks really complicated. |
380 | 380 |
|
381 | | -00:12:12 What, you know, how is this A6 supposed to work? |
| 381 | +00:12:12 What, you know, how is this Async supposed to work? |
382 | 382 |
|
383 | 383 | 00:12:14 And then you look back and go, oh, that's all. |
384 | 384 |
|
|
414 | 414 |
|
415 | 415 | 00:13:30 Let's go all the way down into the internals and how this actually works under the hood. |
416 | 416 |
|
417 | | -00:13:37 So by the time you get to the for loop, the web statements, the meta class or whatever, you're like, "Oh, I understand what this is, why it's there, how it's used, and when not to use it." >> Yeah, that's a great service. |
| 417 | +00:13:37 So by the time you get to the for loop, the web statements, the meta class or whatever, you're like, "Oh, I understand what this is, why it's there, how it's used, and when not to use it." Yeah, that's a great service. |
418 | 418 |
|
419 | 419 | 00:13:48 So you're saying if I create a class called like, user factory and it implemented I user factory, and then I would use dependency injection, I might be doing that wrong? |
420 | 420 |
|
|
446 | 446 |
|
447 | 447 | 00:15:14 Sentry has taken a different approach, building the most affordable APM solution in the market. |
448 | 448 |
|
449 | | -00:15:19 They've removed the noise and extract the maximum value out of your performance data while passing the savings directly onto you, especially for TalkBython listeners who use the code TalkBython. |
| 449 | +00:15:19 They've removed the noise and extract the maximum value out of your performance data while passing the savings directly onto you, especially for Talk Python listeners who use the code TalkBython. |
450 | 450 |
|
451 | 451 | 00:15:30 So get started at talkpython.fm/sentry and be sure to use their code, talkpython, all lowercase, so you let them know that you heard about them from us. |
452 | 452 |
|
|
500 | 500 |
|
501 | 501 | 00:17:01 - Yeah, yeah. |
502 | 502 |
|
503 | | -00:17:01 - And I thought I was being super clever and I wasn't, but eventually someone explained to me, I think it was actually Ned Batchelder, someone gave me the link to Ned Batchelder's talk on this, is that Python's variables work very differently than other languages, so much so that some smart alecks like to say, well, Python doesn't really have variables. |
| 503 | +00:17:01 - And I thought I was being super clever and I wasn't, but eventually someone explained to me, I think it was actually Ned Batchelder, someone gave me the link to Ned Batchelder's talk on this, is that Python's variables work very differently than other languages, so much so that some smart alex like to say, well, Python doesn't really have variables. |
504 | 504 |
|
505 | 505 | 00:17:18 Yes, it does, but they're variables in a different sense. |
506 | 506 |
|
|
568 | 568 |
|
569 | 569 | 00:20:18 That's a bit of a mental thing. |
570 | 570 |
|
571 | | -00:20:20 People got to get used to just like how much, because when you come from a language like C plus plus or something, pointers and these reference type type of ideas are like right in your face. |
| 571 | +00:20:20 People got to get used to just like how much, because when you come from a language like C++ or something, pointers and these reference type type of ideas are like right in your face. |
572 | 572 |
|
573 | 573 | 00:20:30 Right? |
574 | 574 |
|
|
640 | 640 |
|
641 | 641 | 00:23:12 There's global level, there's module level, and there's I need to back. |
642 | 642 |
|
643 | | -00:23:18 It's a little pedantic. |
| 643 | +00:23:18 It's a little pydantic. |
644 | 644 |
|
645 | 645 | 00:23:20 And then you have function level classes are not their own scope. |
646 | 646 |
|
|
776 | 776 |
|
777 | 777 | 00:28:41 And then you get generator methods with the yield keyword and yield from and like all sorts of stuff. |
778 | 778 |
|
779 | | -00:28:46 You, you get PyTest fixtures that allow you to set up and tear down without actually writing try finally blocks and all these things. |
| 779 | +00:28:46 You, you get Py Test fixtures that allow you to set up and tear down without actually writing try finally blocks and all these things. |
780 | 780 |
|
781 | 781 | 00:28:55 A lot, a lot of interesting places. |
782 | 782 |
|
783 | 783 | 00:28:57 While I was thinking about this conversation and this topic in particular, I ran across an article called static duck typing in Python with protocols. |
784 | 784 |
|
785 | 785 | 00:29:05 How's that to like crash two ideas together? |
786 | 786 |
|
787 | | -00:29:08 Yeah, it's well, and it's, well, when we look at data types, it's like the way Python even does its data types is yeah, you can say that you want to say, okay, this is a list and you can type it as a list, but you can also just actually type it as a neverable and basically tell Python what you care about. |
| 787 | +00:29:08 Yeah, it's well, and it's, well, when we look at data types, it's like the way Python even does its data types is yeah, you can say that you want to say, okay, this is a list and you can type it as a list, but you can also just actually type it as a iterable and basically tell Python what you care about. |
788 | 788 |
|
789 | 789 | 00:29:27 Do you really care that it's a list? |
790 | 790 |
|
|
882 | 882 |
|
883 | 883 | 00:32:09 And using a CDN to make your Python apps faster is way easier than you think. |
884 | 884 |
|
885 | | -00:32:14 So if you've got a Python web app and you would like to have it scaled out globally, If you'd like to have your users have a much better experience and maybe even save some money on server hosting and bandwidth, check out this course over at talk, python.fm/courses. |
| 885 | +00:32:14 So if you've got a Python web app and you would like to have it scaled out globally, If you'd like to have your users have a much better experience and maybe even save some money on server hosting and bandwidth, check out this course over at talkpython.fm/courses. |
886 | 886 |
|
887 | 887 | 00:32:30 It'll be right up there at the top. |
888 | 888 |
|
|
894 | 894 |
|
895 | 895 | 00:32:38 I'm back to the show. |
896 | 896 |
|
897 | | -00:32:39 Iteration, iterables, iterators, Lubin. |
| 897 | +00:32:39 Iteration, iterables, iterators, Looping. |
898 | 898 |
|
899 | 899 | 00:32:45 Yes. |
900 | 900 |
|
901 | | -00:32:46 So I was working in some code last year and I came across something that just, I, I, I was, I cringed and then I laughed out loud because this was written. |
| 901 | +00:32:46 So I was working in some code last year and I came across something that just, I, was, I cringed and then I laughed out loud because this was written. |
902 | 902 |
|
903 | | -00:32:55 So this code was written by who I best guess university data scientists. |
| 903 | +00:32:55 So this code was written by who I best guests university data scientists. |
904 | 904 |
|
905 | 905 | 00:33:01 So, you know, a, to their favor, this is not a software engineer. |
906 | 906 |
|
|
966 | 966 |
|
967 | 967 | 00:35:16 - Yeah. |
968 | 968 |
|
969 | | -00:35:17 - If you talk SQLAlchemy, right? |
| 969 | +00:35:17 - If you talk SQL Alchemy, right? |
970 | 970 |
|
971 | 971 | 00:35:18 I'm gonna do a query, I could call the all method and turn it into an in-memory list, or I could, if I don't need that, I could just loop over it, right? |
972 | 972 |
|
|
1192 | 1192 |
|
1193 | 1193 | 00:45:06 So in Unix systems like Linux and Mac, there's a bin folder. |
1194 | 1194 |
|
1195 | | -00:45:10 So them slash bin slash and then whatever Python by whatever Python executable you want to run. |
| 1195 | +00:45:10 So them/bin/ and then whatever Python by whatever Python executable you want to run. |
1196 | 1196 |
|
1197 | 1197 | 00:45:16 It could be Python, it could be pip, it could be your own package. |
1198 | 1198 |
|
1199 | 1199 | 00:45:19 You can actually just navigate into that bin folder. |
1200 | 1200 |
|
1201 | | -00:45:22 And so I can say them bin pip, and I've got the pip and that knows to only work within its virtual environment. |
| 1201 | +00:45:22 And so I can say them venv pip, and I've got the pip and that knows to only work within its virtual environment. |
1202 | 1202 |
|
1203 | 1203 | 00:45:29 It's not going to break out of that container. |
1204 | 1204 |
|
1205 | 1205 | 00:45:30 Once you understand that, here's where the activate script is. |
1206 | 1206 |
|
1207 | | -00:45:33 Them bin activate. |
| 1207 | +00:45:33 Then bin activate. |
1208 | 1208 |
|
1209 | 1209 | 00:45:35 It lives in the bin file. |
1210 | 1210 |
|
|
1232 | 1232 |
|
1233 | 1233 | 00:46:34 I just have a short version, so I know it's something slightly different, but it'll go run the virtual environment and it'll always remember to add --prompt=. |
1234 | 1234 |
|
1235 | | -00:46:42 which will make the virtual environment not just be called VE and V, but it'll be called the name of the project that it's in. |
| 1235 | +00:46:42 which will make the virtual environment not just be called VENV, but it'll be called the name of the project that it's in. |
1236 | 1236 |
|
1237 | 1237 | 00:46:48 So for example, if it's in like Talk Python, like the virtual environment, when I activate it, it will say it's the virtual environment Talk Python, right? |
1238 | 1238 |
|
|
1252 | 1252 |
|
1253 | 1253 | 00:47:24 Why don't we fix that? |
1254 | 1254 |
|
1255 | | -00:47:24 So my alias then says, pip install -upip, setup tools, wheels, pip-tools, et cetera, and just ditches that output. |
| 1255 | +00:47:24 So my alias then says, pip install -upip, setup tools, wheels, pip-tools, etcetera, and just ditches that output. |
1256 | 1256 |
|
1257 | 1257 | 00:47:31 So like, right, immediately, like I have, when I create a virtual environment, it's immediately active and it's immediately named the project and it's immediately up to date. |
1258 | 1258 |
|
|
1300 | 1300 |
|
1301 | 1301 | 00:48:58 I was very happy with myself. |
1302 | 1302 |
|
1303 | | -00:49:00 And then I spent the next two years trying to package the dark peg. |
| 1303 | +00:49:00 And then I spent the next two years trying to package the dark thing |
1304 | 1304 |
|
1305 | 1305 | 00:49:03 Turned out it was impossible to package because of certain assumptions that one of the libraries I was using made. |
1306 | 1306 |
|
|
1344 | 1344 |
|
1345 | 1345 | 00:50:34 Yeah. |
1346 | 1346 |
|
1347 | | -00:50:35 Currency. |
| 1347 | +00:50:35 Concurrency. |
1348 | 1348 |
|
1349 | | -00:50:35 Currency. |
| 1349 | +00:50:35 Concurrency. |
1350 | 1350 |
|
1351 | 1351 | 00:50:36 Yes. |
1352 | 1352 |
|
|
1372 | 1372 |
|
1373 | 1373 | 00:51:16 You're not really multitasking, you're just changing your focus fast enough that no one ever notices the difference. That's concurrency. So you have one CPU or potentially, potentially multiple remote this where people get confused. Python's nice because you're locked the one CPU for concurrency. So it's I'm gonna work on this, then I'll work on this and work on this, then work on this, it doesn't make your code faster. |
1374 | 1374 |
|
1375 | | -00:51:38 It'll never make your code faster, just like multitasking will not make you get through your workday faster. What it's going to do is it's going to slow you down. But it doesn't look like is in some cases, it'll make your code look faster. Because while you're waiting on the user to type in their answer, this example I use the book, or you're waiting on the user to type in their answer to a question, you're doing some math in the background, your IO blocked, you're waiting on something over which you have no control, you can do some other work while you wait, that's concurrency. And you can do that with a synchrony where Python's handling that multitasking, or you can do with threading where the operating system is handling that multitasking. That's different than parallelism, which is where you're actually using different CPU cores and you're doing two things at the same time, because you have two different CPUs, two different cores working in parallel. And they're not depending on one another. Not they're not waiting. You're doing multiple tasks at once. Both of them have overhead near one is a silver bullet for performance, you're really going to have to think a lot about it. But I actually like the gill for this reason, global interpreter lock the much aligned thing that stops us from getting free multiprocess of free parallelism, free multiprocessing with every thread. |
| 1375 | +00:51:38 It'll never make your code faster, just like multitasking will not make you get through your workday faster. What it's going to do is it's going to slow you down. But it doesn't look like is in some cases, it'll make your code look faster. Because while you're waiting on the user to type in their answer, this example I use the book, or you're waiting on the user to type in their answer to a question, you're doing some math in the background, your IO blocked, you're waiting on something over which you have no control, you can do some other work while you wait, that's concurrency. And you can do that with a synchrony where Python's handling that multitasking, or you can do with threading where the operating system is handling that multitasking. That's different than parallelism, which is where you're actually using different CPU cores and you're doing two things at the same time, because you have two different CPUs, two different cores working in parallel. And they're not depending on one another. Not they're not waiting. You're doing multiple tasks at once. Both of them have overhead near one is a silver bullet for performance, you're really going to have to think a lot about it. But I actually like the GIL for this reason, global interpreter lock the much aligned thing that stops us from getting free multiprocess of free parallelism, free multiprocessing with every thread. |
1376 | 1376 |
|
1377 | 1377 | 00:52:48 Because this forces us to actually stop and think, which thing do I need? |
1378 | 1378 |
|
1379 | 1379 | 00:52:53 Do I need concurrency or do I need parallelism? |
1380 | 1380 |
|
1381 | | -00:52:56 Because you can get both in Python, but the gill makes sure that you have to make a decision. |
| 1381 | +00:52:56 Because you can get both in Python, but the gil makes sure that you have to make a decision. |
1382 | 1382 |
|
1383 | 1383 | 00:53:01 Because if you want multiprocessing, you're going to have to create different processes, spin them off, manage them separately. |
1384 | 1384 |
|
|
1406 | 1406 |
|
1407 | 1407 | 00:53:51 Could I be doing something while I'm waiting? |
1408 | 1408 |
|
1409 | | -00:53:53 And async and await amount, it makes it super easy to do stuff while you're waiting, but your program itself is still constrained by the gill and often with async and await, there's not even a second thread involved, right? |
| 1409 | +00:53:53 And async and await amount, it makes it super easy to do stuff while you're waiting, but your program itself is still constrained by the gil and often with async and await, there's not even a second thread involved, right? |
1410 | 1410 |
|
1411 | 1411 | 00:54:06 It's just slicing up time, slicing up the current thread. |
1412 | 1412 |
|
|
1502 | 1502 |
|
1503 | 1503 | 00:56:35 And I think that's one thing I wanted to say is when I was writing this book, that was the thing that was my chief delight was coming up with examples for all of the topics from the simplest, all the way to the most complicated, where I did not hold back on the relevant complexity. |
1504 | 1504 |
|
1505 | | -00:56:49 My list comprehensions were the starliest list comprehensions you're ever going to find in this tutorial. |
| 1505 | +00:56:49 My list comprehensions were the starlist list comprehensions you're ever going to find in this tutorial. |
1506 | 1506 |
|
1507 | 1507 | 00:56:54 You know, my, you know, I have, I go into recursion. |
1508 | 1508 |
|
|
1572 | 1572 |
|
1573 | 1573 | 00:59:28 I guess I have two. |
1574 | 1574 |
|
1575 | | -00:59:30 One would be, I think my favorite, and this has certainly gotten plenty of press, but I love it. |
| 1575 | +00:59:30 One would be, I think my favorite, and this has certainly got plenty of press, but I love it. |
1576 | 1576 |
|
1577 | 1577 | 00:59:34 It's the hypothesis testing library. |
1578 | 1578 |
|
|
1630 | 1630 |
|
1631 | 1631 | 01:01:27 Yes. So that's a book I thought is available from wherever you buy books, but especially if you go to no starch.com, you can get this comes in ebook or in physical book form. |
1632 | 1632 |
|
1633 | | -01:01:38 And, Hey, you know what? I wrote it and I refer to it every single day because this is This is the book I wish I had had. |
| 1633 | +01:01:38 And, Hey, you know what? I wrote it and I refer to it every single day because this is the book I wish I had had. |
1634 | 1634 |
|
1635 | 1635 | 01:01:43 And my favorite little feature of this is that I have a thing in the back with every single command for the debugger. |
1636 | 1636 |
|
|
1640 | 1640 |
|
1641 | 1641 | 01:01:55 This is the entire core language, bar nothing, explained for the existing coder. So, check this out. |
1642 | 1642 |
|
1643 | | -01:02:01 From nostars.com. |
| 1643 | +01:02:01 From nostarch.com. |
1644 | 1644 |
|
1645 | 1645 | 01:02:03 Well, thanks for taking the time for being here and enjoy the chat. |
1646 | 1646 |
|
|
1693 | 1693 | 01:03:21 Now get out there and write some Python code. |
1694 | 1694 |
|
1695 | 1695 | 01:03:22 [MUSIC] |
1696 | | - |
0 commit comments