Building data-driven web apps with Pyramid and SQLAlchemy Transcripts
Chapter: Introducing the Pyramid framework
Lecture: Pyramid principles
0:00 Let's spend a moment on the Pyramid philosophy
0:03 and some of the principles that they use
0:05 to drive their project.
0:06 I love their tagline:
0:08 The start small, finish big, and stay finished framework.
0:12 You'll see that the principles
0:13 really drive that mission statement there.
0:16 First of all, they focus on simplicity,
0:19 and the pay-only-for-what-you-eat approach.
0:22 And what that means is they've designed the framework
0:25 so that you can get results even if you have
0:28 only a partial understanding of Pyramid.
0:30 You don't need to understand all the stuff
0:32 in order to make use of it.
0:34 You just need to know how to, say,
0:35 create a view and a template and pass data to it.
0:38 That's really all you need to know
0:39 if you just want to show simple data, things like that.
0:42 So they've built this start small and add your understanding
0:47 to do more and more advanced stuff over time
0:49 but if you don't care about it,
0:50 you don't need to know about it, and that's really nice.
0:53 Being a microframework, they focus on minimalism;
0:57 the core things that web applications do:
0:59 mapping URLs to code, templating,
1:02 security, and static assets.
1:04 And that's pretty much it.
1:05 Every web application has to do stuff like this,
1:07 so that's what they've focused on,
1:09 doing this really fast and really well.
1:13 Because Pyramid's relatively small,
1:15 they can focus on having documentation for everything.
1:19 So their goal is to make sure nothing goes undocumented.
1:22 And I could tell you, I've submitted a couple of PRs
1:24 back to various aspects of Pyramid
1:26 and a lot of the conversation actually has been,
1:29 well, what are the effects of this change
1:31 on the documentation, on the tutorials,
1:33 and making sure that that's always up to date.
1:36 Maybe even more so than,
1:38 is this the right change for the framework?
1:40 So I can tell you they take documentation super seriously.
1:44 We talked about focusing
1:46 on the core things the web framework does,
1:48 routing URLs, serving static assets, and so on,
1:51 and I can tell you that Pyramid
1:53 is one of the fastest Python web frameworks out there.
1:57 It's super fast, really runs well,
1:59 and it runs well on Python 3.
2:01 Some of the frameworks out there,
2:02 you'll see they run pretty fast on Python 2
2:04 but not on Python 3,
2:05 and nobody wants to be in that place these days, right?
2:08 Python 2 is on its way out, so having this run fast
2:11 on Python 3 is really, really awesome.
2:14 I can give you a little bit of background
2:15 just running Pyramid for my web applications,
2:18 both the podcast website
2:20 and the training website run on Pyramid.
2:22 I've had various things of those sites each featured
2:27 on Hacker News, and be on the front page,
2:30 in the top five or top 10 on Hacker News for a day or two,
2:34 and that sends a ton of traffic over.
2:36 You go over to the web server, pull it up,
2:38 it's like a $5/10 web server, virtual machine,
2:41 and it's doing like 5/10% CP usage
2:45 even though it's just getting hammered
2:47 with all this traffic. So this framework is super fast and easy on the hardware,
2:51 and really, really scales in some impressive ways.
2:55 We obviously want our web frameworks to be reliable,
2:58 and it's really encouraging that every release of Pyramid
3:01 has 100% statement coverage for their unit tests.
3:04 That's awesome.
3:06 Pyramid is open source and released
3:09 under a permissive license.
3:10 You can see your github.com/pylon/pyramid,
3:13 and you can go check it out, download it, clone it,
3:16 do whatever you want so you'll always
3:18 have access to your web framework.
3:22 One of the first things that drew me to Pyramid was actually
3:25 it's super strong support for Python 3.
3:29 So they made a statement early on saying,
3:32 Python 3 is the future,
3:33 Python 3 is going to be our default implementation.
3:36 Yes, it may still run on Python 2,
3:39 but we are going to build all of our demos,
3:42 build all of our examples,
3:43 and primarily test and develop on Python 3,
3:47 and make sure things run fast on Python 3.
3:50 Which they've done really well, and that's awesome.
3:53 You definitely need to be on Python 3 these days,
3:55 Python 2 is on its way out really, really soon.
3:58 At the 2020 deadline, it's basically going unsupported
4:02 and you do not want to be built on a framework
4:04 or a runtime that's unsupported.
4:07 So the fact that Python 3 is the default implementation
4:10 for Pyramid is just excellent.