Learn Python with Talk Python's Python courses


« Return to show page

Transcript for Episode #248:
Climate change and your Python code

Recorded on Wednesday, Dec 11, 2019.

00:00 Michael Kennedy: The most critical issue of our time is climate change. Yet, when you think about our carbon impact in the software industry, what comes to mind? Business travel? Commuting to the office so you don't miss filing that TPS report? Yeah, those are bad, but data centers, servers and our apps consume a substantial portion of the total energy used by modern humans. In this episode, you'll meet Chris Adams. He's been advocating for a greener software environment and has concrete advice to make your Python programs more climate friendly. The good news is, generally speaking, what we need to do to make our code easier on the planet is the same things we do to make our code faster. Dive into software and climate on this episode, number 248, recorded December 11th, 2019. Welcome to Talk to Python to Me, a weekly podcast on Python, the language, the libraries, the ecosystem, and the personalities. This is your host, Michael Kennedy. Follow me on Twitter where I'm @mkennedy. Keep up with the show and listen to past episodes at talkpython.fm and follow the show on Twitter via @TalkPython. This episode is sponsored by brilliant.org and Datadog. Please check out what they're offering during their segments, it really helps support the show. Chris, welcome to the Talk Python with me.

01:26 Chris Adams: Oh, thank you very much for having me, Michael.

01:27 Michael Kennedy: I'm really excited to have you on the show. This is a topic that I've not covered a ton. We have had a previous show on studying climate science in Python, but we haven't really dove into how that affects us individually and how the ways that we write software or think about how we host our code or even how fast our website responds directly can correlate to, contributing to, or alleviating some of the pressure on emissions. And so those types of things are going to be so fun to talk about with you.

01:55 Chris Adams: Cool, I'm looking forward to it. The thing I can tell you is that if it's new to you, you're in good company. There's lots and lots of people, and I say this with love, who figured out that yes, the internet is often someone else's computer, but that means someone else's computer is run on electricity. And in many cases that comes from us burning fossil fuels or things. And so, you're definitely not the only person to be thinking about this. And more and more of us are waking up to this fact and realizing that we are in quite a pivotal position to change how we work and end up working in a more kind of planet friendly way, I feel.

02:27 Michael Kennedy: There are so many things that are low hanging fruit that we can do, right? I mean, obviously this is a big problem that needs big solutions, but look, if stuff's easy, let's do it. So we're going to talk about that. Now, before we get into that whole side of things, let's just start with your story. How'd you get into programming and Python?

02:42 Chris Adams: I actually got into programming, not through university or anything like that. I actually studied to become a doctor and partly because when I was growing up, my parents were really, really keen on me becoming a doctor. So yeah, I'll be a good kid, I'll try and become a doctor. Then I kind of discovered photography and I got really into that in high school and I got so excited about that that my plans for kind of going to, say, go to Oxbridge or something basically fell by the wayside. And I got really, really into studying things like media and film and I went from there to basically study photography, film making, video production, stuff like that, playing with these things. And, I'm showing my age when I say this now, but I was, this is around the turn of the century. We were just starting to kind of start playing with things like Final Cut Pro and digital video because when I was studying this we were literally, you know about cut and paste?

03:29 Michael Kennedy: Yes.

03:30 Chris Adams: I ran it with cut and... When we were making films, we were using hand-winding films, a kind of Bolex camera. We literally had to kind of cut film and paste it to make films.

03:40 Michael Kennedy: That is a really, really hard way to edit video together, right? I mean, now it's like splice, splice, splice, digital this, transforms that. It's crazy. But that's how it was, right? The world has changed so much...

03:51 Chris Adams: Absolutely.

03:52 Michael Kennedy: In 20, 30 years and it's easy to forget.

03:53 Chris Adams: Exactly, so we did this and at the time there was this thing which was called new media, which was other ways of kind of expressing yourself or exploring things. And through that there was this kind of interest in this thing called digital. So I kind of started playing around with things like Dreamweaver or ActionScript or stuff like this. And I thought, "Wow, this is kind of cool." Because there was a load of really interesting art in this field right now because people were trying to explore the medium and what any of that's actually meant or what kind of kind of impact it would have socially for us, really. And on the course I was studying, you are basically given quite a lot of freedom, almost too much freedom. So when we end up graduating, a lot of us had kind of black and white films about ourselves, which was, I didn't find that interesting myself. But, we also had a chance to just mess around with computers to either explore an idea, or I guess try and build some kind of installation or something which would help you interrogate an idea that you might've come across in your kind of art culture part. And we had a kind of media education part of the course I did and a large part was about things like, say, media ownership and things like the California Now Ideology and loads of really wild ideas that came over us, which in the turn of the century seemed like bonkers concepts. There was this idea called suveillance, like the way we might kind of relate to computers. You had kind of cultural commentators and artists talking about, "Imagine what it's going to be like when everyone has computers and everyone can frame everything."

05:25 Michael Kennedy: Right, right.

05:25 Chris Adams: Yeah!

05:26 Michael Kennedy: And now here we are with our cell phones, right? It's here.

05:29 Chris Adams: Yeah! I got into this idea, and one of the things I started working... I really got interested in was this idea by this theorist called Jamais Cascio. I think I'm pronouncing his name properly. He spoke about this idea of the participatory panopticon, that when we all have cameras there will be no real common concept of privacy and we'll forever be kind of recording things and sharing things. And there was this kind of idea that rather than having kind of big brother, there was millions of little brothers. And, that has all kinds of ramifications on how we relate to... So I ended up working with a friend of mine 'cause I couldn't really code at this point. I was just some, I dunno some art student, really. And I lived in a part of town which was kind of rough because I didn't know how hard it would be. I thought, well maybe we can get a linux box, find a way to run it in the car, run it off a 15-pound webcam, connect to some GPS and some wifi, run this all off the cigarette lighter of the car and build something like a kind of panopticon thing for ourselves to see how that might change how we think about it. Yeah, and because we had this whole notion of... Because on the course there was all this conversation about say, the kind of Californian Ideology and Silicon Valley in this way, that in many cases lots of companies present themselves as changing the world. We figured, well maybe we can kind of dress up in some of that language to explore this as an idea. So rather than make a film, I figured, let's try to create some kind of intervention using open source software and a kind of cultural, I guess, thing. So I basically built this thing with a friend of mine, or more specifically, my friend did all the coding whilst I was learning how to kind of code and kind of do some of this, and work out what ring buffer was and everything. And we built a thing, which basically was a giant red button on a dashboard hooked up to a webcam that ran a ring buff in front of you. And what would happen is when you're driving around, if someone cuts you off, rather than screaming at them, because who knows, they might be carrying a knife or a gun or something, you pull over and you just hit this button like, "Ah, ah, ah, God damn it, why can't they drive properly?" And that would catch where and how that person almost hit you, with the idea being that when you drive home, when you're on the wifi, you'd upload this video to YouTube or somewhere. And the great thing about this is that, well, cars have really handy foreign keys called number plates. And if you can then expose a feed of this, you could create some kind of business model around this. So we kind of, as a kind of, I don't know, artsy statement accidentally ended up building dash cams. All right? With the idea being that...

07:53 Michael Kennedy: Right, right, yeah, exactly.

07:54 Chris Adams: Yeah! So we figured like, "Hey, wouldn't it be weird if people had something like this? Wouldn't that be like, end up with all these strange implications?" Because we kind of designed a business model as an art project around, well, if you provide this information then maybe the thing that you might get, you might get an incentive to basically film everyone else doing this if you got cheaper insurance premiums. And because insurance companies don't need to disclose how they price you, you could have this idea where you could present the idea that you're pricing people off the roads for bad driving, but instead create this kind of horrifying dystopian scale scape where everyone's continually filming each other. And that seemed more interesting than making a film.

08:31 Michael Kennedy: That's a pretty interesting social experiment, yeah. Where'd it go?

08:35 Chris Adams: Oh, well we... So here's the other thing. There is an idea called, if you work with IP, Intellectual Property, there's a phrase called prior art. And we thought, "Oh my God, this is horrifying what we're building. Now that we've explored this, the implications are terrifying." So we figured, well, one thing we can do is let's take this prior art idea quite literally and put it in a gallery, so it's literally prior art. And if you do it that way, then you cannot paint into because it's kind of toxic and no one can makes any money off it. And of course, we were naive students, all right? So like I'm pretty sure a couple of large companies have found ways to make money out of data, now. But this was an idea like, "Yeah, as if anyone would really do that, right?" And that was kind of my first exposure into coding and that was actually Ruby initially, with little bits of a C and stuff. But I found the two of them quite difficult and especially back then. And then when I graduated I was looking for something similarly interesting and out there and I couldn't find much. But the person who I built that with, I mean he only built this 'cause he was doing a cognitive science course and he thought some of the ideas, some of my ideas were kind of funny. We ended up setting up a company where we figured we're only going to work on open source nice things. And we ended up working in a coworking space and find ourselves working on bits of Django or doing some kind of internet of things related stuff. I think I've just shared a link to some of the earliest code I've ever contributed to. And like my first Python as a person who could barely write HTML was diving straight into Twisted and oh!

10:06 Michael Kennedy: Oh my goodness!

10:07 Chris Adams: I'm not sure that was the first code I should have written, right?

10:11 Michael Kennedy: Yeah, that's definitely mind bending that async stuff but... Well look, if you can start out by building, recreating dash cams in the software and the hardware side and then you can go contribute or work on code that's for Twisted, I think you'll be alright.

10:26 Chris Adams: Well, that was actually a kind of interesting... That project, the Twisted stuff. There's a story around that, actually. So what we were doing, we're in this coworking space and we were thinking, well wouldn't it be cool if you could help people understand that there is an environmental impact to how we use buildings, and maybe if you can do something, what we might call now, like flexible pricing around coworking space to kind of incentivize people to use it when it's not so much. So, think of it like load balancing or demand shifting but with people rather than service. So we ended up working on some things to basically work out the carbon footprint per person per hour of space by inferring presence on wifi. We're looking at it by tracking the Mac addresses in a coworking space, 'cause we could...

11:09 Michael Kennedy: Interesting.

11:10 Chris Adams: Pretty much figured out, if there is maybe... Every single person has a phone and a laptop, if you can count the laptops and the phones and you can more or less associate them with each other, then you get an rough idea of occupancy and usage of spaces here. And if you know how much energy you're using, you can work out that out as well.

11:26 Michael Kennedy: Right, and mostly that's probably heating, cooling, that kind of stuff, not people plugging in their laptops.

11:29 Chris Adams: Absolutely.

11:30 Michael Kennedy: So if there's one person versus 10 people, it costs almost 10 times as much for that one person in terms of energy, right?

11:36 Chris Adams: Absolutely, right. So this was one thing you could do. So if you can encourage people to kind of scrunch together to use that space more efficiently, then you've got a much more efficient use of that space per person. And if you think in terms of, not buildings, but providing working space, again, which is kind of what you see now, there are so many kind of lucrative businesses that I've failed to kind of take forward.

11:58 Michael Kennedy: You've been really early at a lot of these things, right?

12:01 Chris Adams: Yeah. We end up doing a load of stuff like that. And that was my exposure to messing around with Python and Twisted because we said, "Oh yeah, we could do that!" Because you figured, you'd be just reading RFID cards, right? And then my friend Fred Fix, who now lives in Berlin and is a CTO of some of the same companies we were working on part time with that, we basically had to find a way to make these things speak to some parts of the building to trigger some actuators for sliding doors to work. And in order to do that we figured, well we'll use Twisted and we need a server to make a door work. So the link I've shared is doord because it's sort of like daemon for a door.

12:33 Michael Kennedy: Oh, nice!

12:36 Chris Adams: And we had all these ideas look to this because the space we're in, they had an OpenLDAP installation for the members. So at one point, we kind of hooked this up so that when you walked in or tapped your RFID card, because you could make that speak to the speakers you could have your theme song walk in. Or you could have loads of silly ideas like that. 'Cause if you could... Yeah, I mean it's, if you can think of an entire building as like a gigantic Linux box, then there's kind of fun things you can do.

13:00 Michael Kennedy: Yeah, that's really clever, I like it.

13:02 Chris Adams: Yeah, We also realized there's loads of silly things you can do as well. I mean, I learned firsthand that, in 2007, I think, I've realized that if you put a door on the internet and you expose an IP address for anyone to use, then we end up with scenarios where you had loads of hacking attempts from China trying to kind of pwned the door because they just saw it as an IP address. And we ended up having quite a few phone calls like, "Chris, yeah the door's gone a bit weird again. Can you fix that please?" I'm like, "Yeah."

13:29 Michael Kennedy: The door's got a DDoS attack on it. What are we going to do?

13:33 Chris Adams: Yeah, yeah, yeah, yeah yeah. I'm sure there's a joke about doors and dd doors and something there, right? But yeah, the dos the door. But anyway there was something about... But we also, when we were working with this, I've realized that there's a reason hardware is called hard-ware. And I decided to make... Okay, let's work with software a bit more. And then I started working with Django a bit on a couple of other projects, and I found Django really, really nice as a framework to work with 'cause it was really well documented and I found the community quite friendly. And yeah, that's probably how I got into programming, was kind of artsy student trying to implement things, realizing that I didn't know what I was doing and then realize I had to actually run some of this myself and had to learn how to use servers and stuff. So, I have a bit of a patchy background and only in like 2016 did I really start reading about data structures and then I went, "Oh God, this would have been so much easier if I could only know this 10 years ago."

14:21 Michael Kennedy: Exactly, this would have totally... We created this, why did I create this? It just exists now.

14:24 Chris Adams: Yeah!

14:26 Michael Kennedy: Man, what a cool series of getting into it, get into programming experiences. Those are great. So what are you doing now?

14:34 Chris Adams: At the moment I am splitting my time working with one group called the Green Web Foundation where I am currently helping them kind of rebuild chunks of their stuff in Django and splitting my time working with a group called climateaction.tech. And, generally working as a kind of consultant, product manager, consultant. I've still got where groups will basically work with me and hire me to help them think through their process. But I still got a few old Django clients I've been looking after and I still work with every now and again. So I do a kind of a bit of a mixed grab bag of all this stuff but increasingly, I find myself doing a lot more work with tech and climate and specifically, speaking to techies who have said, "Hey, I want to do something more responsible with my skills." or "We're building a project and we figured out that we're using electricity to run computers and maybe we should think about that part there." Or, "I'm planning to set up some kind of practice around how we build digital products and we want to be a bit more responsible about the unintended consequences that we might have when working on that." So we're doing a bunch of these things. And I've started writing about this stuff in a newsletter called Greening Digital because, well, greening how we do digital, it seemed like a relativity straightforward thing. So that's what I do. And so yeah, basically bits of coding and evangelism stuff with the Green Web Foundation and a grab bag of mixed stuff, which tends to be Python in many cases 'cause it's become the language I'm most comfortable working in. And it's useful because it's the second most popular language in the world now. So the chances are that things have been implemented by someone who's thought about it longer than you have.

16:06 Michael Kennedy: Absolutely. There's so many different libraries you can grab. Those are a bunch of cool projects and organizations. So, the Green Web Foundation idea is, one day the internet will run entirely on renewable energy and they develop tools to help speed that up, right? So you're helping them with with that. And then the Climate Action is a global community of tech professionals using their expertise to support solutions for climate change.

16:27 Chris Adams: Yeah, that's pretty much it.

16:28 Michael Kennedy: Nice, you'll have to give me the link to your newsletter so I can put it in the show so people can subscribe.

16:32 Chris Adams: Yeah, absolutely.

16:36 Michael Kennedy: This portion of Talk Python To Me is brought to you by brilliant.org. It's early 2020 and many of us have made new year's resolutions. The best resolution you can keep is investing in your STEM skills. Whether you're a student, a professional brushing up on cutting-edge topics, or someone who just wants to understand the world better, brilliant.org makes it easy with interactive explorations and a mobile app that you can use on the go. If you're naturally curious, want to build out your problem solving skills or need to develop confidence in your analytical abilities, then get Brilliant Premium to learn something new every day. Brilliant's thought provoking math, science and computer science content helps guide your mastery by taking complex concepts and breaking them into bite size understandable chunks. Get started by visiting talkpython.fm/brilliant or just click the link in your podcast player. Let's talk about, climate change at the high level, just before we dive into how can we write code that alleviates that pressure and maybe is a better citizen of the world digitally speaking. And also, the real effects that it actually has. And you talked about all this using energy, in particular electricity, right? Servers run on electricity, MacBooks run on electricity. There's a lot of negative news here, but one of the things that I see as a real sliver of hope, let's put it like that in terms of this part of the slice is electricity is awesome because it often does come from nasty sources like burning coal, but it can come from solar panels, it can come from wind, it can come from... Right? It can come from...

18:10 Chris Adams: Yes!

18:11 Michael Kennedy: numerous places. So it's like you don't have to change anything. You don't have to change anything at all to completely turn all that stuff to renewable foundations. You just need to change the generation of it, right?

18:21 Chris Adams: Yes, absolutely.

18:21 Michael Kennedy: If it was, like, airplanes are a serious problem, right? Or cars, we're working on electric cars, we're getting there, but it's... Diesel trucks, it's super hard to just say, "Well all you got to do is plug it into a different source." No, diesel comes from a place where it's really hard to make that carbon neutral or renewable, right? So in some sense the story around tech climate is kind of positive in that regard, I think. How do you feel?

18:43 Chris Adams: Yeah, I'm really, really glad you started framing it this way because I think it's really important for us to realize that a lot of the things that we know and love, like the internet for example, it doesn't need to be running on fossil fuels. And what you spoke about before was the issue is, in many cases, it's our use of fossil fuels and where we get energy from, not necessarily some of the kind of the life choices we make. Yes, there is obviously going to be consequences of burning huge amounts of fossil fuels. If we're flying across the Atlantic every second week, for example, but if there was a way to basically do that without the CO2 emissions from burning fossil fuels, and increasingly we are seeing options to make that possible, then I think it's actually, that suggests to us that there's actually a kind of more positive future that we can have available to us. I don't know about you folks, but I don't remember the internet changing or my experience of Google changing when they switched to green power or when Facebook switched to running on renewable power. It's not like the internet started juddering to a halt and it started working...

19:49 Michael Kennedy: It used to be really fast, but now it's kind of clunky. It doesn't quite work out as well or whatever. No, it's not a steam engine, right? It's electricity.

19:56 Chris Adams: Yeah, this is the thing. I mean this is actually, when we zoom out outside of technology, you'll see that there's a whole conversation around how do we address some of the wider scales? And there was this phrase, kind of electrification, like we need to electrify a lot of the sources of energy that we use because a lot of it comes down to our use of energy, not fossil fuels, but we have in many cases kind of grown up with this idea that the only way you can get energy is from fossil fuels. And in our, cripes! Even when it comes to something like aviation, there are actually ways where you can use, say, excess electricity to create the kind of chemical energy in a way that you could use for say, something which needs a high amount of energy density, like say flying or trucks or something like that. The only problem is we often, over the last 40 or 100 years or so, we've been not really accounting for all the costs of getting fossil fuels out of the ground and putting them into the sky. And as a result, we default to basically drilling for fossil fuels when there are other better ways of experiencing a lot of the same upsides without the unintended consequences that ended up causing avoidable harm.

21:03 Michael Kennedy: Yeah, I totally agree. This whole externality thing is frustrating for sure. You know, Elon Musk, as much as he does crazy stuff and is kind of weird in some ways, I'm a fan of how he's pushing some of these ideas forward around electric cars and so on and solar panels. He came out and said, "Look, if we just took some part of the Southwest United States like Arizona," or something, I think maybe he said Nevada. "And just took a hundred square miles and just covered it in solar panels. "That's enough energy for the entire United States." He also threw in, I dunno, like a five mile square battery or something ridiculous to carry us through the night. But I only know that in terms of the U.S. energy, but that's a huge amount of energy used by the world. It doesn't seem like we as collective citizens of the world are incapable of generating that much renewable energy. It just seems like a matter of will almost. Because surely, we could create enough solar panels to cover a hundred square miles. We pave the earth constantly, right? And that's way more work, or whatever. I mean it just seems like there are these steps that we could take that would not be... They're not science fiction, we've got to create a Dyson sphere around the whole universe, or hold the solar system and channel it back. Now it's just like, it's pretty attainable.

22:13 Chris Adams: So I think this is one of the things that I find both frustrating and inspiring when we have these conversations, because you've mentioned Elon Musk and it's very easy for us to immediately kind of reach for the closest figure to Ironman that we can think of.

22:26 Michael Kennedy: Yeah, exactly.

22:27 Chris Adams: Like, when I grew up totally like, "Yeah, he's like Ironman, but his stuff is open source. This is awesome!" Right? We think about this, but it's also... And when you look at things like the impact that say, well just the kind of mindset that people think about when it comes to things like EVs and making that a reality that's really, really, really good. But you've touched on a few really, really important and interesting things. You need to be able to look, things that are kind of more systemic level. There's a reason why you have these things. And in many cases it's not down to us not having the technology, because we do have the technology. Like right now in 2019 we have seen the cost of batteries fall by something like, I think more than 85%, or around 85%, since 2010. And we've seen an even steeper fall when it comes to solar panels. So it's not like these things are... And to the extent now that, in many cases, deploying new solar is cheaper than continuing to run coal or continuing to run gas-fired power stations and things like that now. And in Europe, for example, which is where I'm from and where I'm most familiar, more than half of the coal-fired power stations that we have now are running at a loss, simply because people have started more accurately pricing the unintended consequences of coal, as well.

23:37 Michael Kennedy: Even in the U.S. where the current administration is doing everything they can to prop up coal, there's still tons, many, many large coal plants shutting down for the same reason that you're talking about. And you were going to talk about the U.K.

23:49 Chris Adams: Yeah, yeah, I was going to bring up the U.K. because the U.K. and the U.S. are, so the U.K. has been one of the fastest countries in Europe to decarbonize its energy, its electricity to the point now that I think recently we've got around 40% of the grid being powered by renewables often, and in many cases it's because, essentially, it's become so expensive to run fossil fuels, and you've seen that, and you're seeing a similar thing in America. America's emissions, or for every kind of unit of electricity has actually been falling pretty quickly. If we just looked at the kind of economics, it would probably be falling even faster. But in many cases you have cases where basically there is a... You have political support to kind of slow down a transition away from a dirty harmful fuel, which employs, I think there are more hairdressers than coal miners in America now, right?

23:49 Michael Kennedy: Oh, yeah.

23:49 Chris Adams: So we have these ridiculous kinds of figures, propping up these industries at the expense of hundreds of millions of jobs in other industries here. And I kind of think that we need to, like when we spoke about Elon Musk here, right? I think there is a degree that yes, it's really cool that we have electronic cars but we also got to think about, well if we are going to give someone all the props for that and basically kind of treat seeing them like some kind of Ironman, but open source kind of hero figure, then I think it's fair for us to expect them to be a bit consistent about who they support politically and who they fund. And if they're going to be funding groups, which basically slow down climate action, then I think we need to be prepared to say, "Hey, it's cool that you're building electric cars, but can you not do the thing which stops us moving away from fossil fuels?" Because I think we're adults and we need to be able to have these complex thoughts in our minds and we also need to be brave enough to actually address the scale of the situation. Because a lot of it is really, really freaking scary, but we are capable of addressing this and facing this as long as we actually just are basically a bit more rational about it in many cases.

23:49 Michael Kennedy: Yeah, absolutely. Absolutely. I totally agree and it's really interesting how it's not really a technology problem, right?

23:49 Chris Adams: It's not.

23:49 Michael Kennedy: It's a technology challenge, but it's not like it's incapable. It's not like we have to envision, we have to invent vision or something like that, right?

23:49 Chris Adams: Yes!

23:49 Michael Kennedy: Now I guess let's just round out this sort of high level view just by pointing out that I think yesterday, I think it was yesterday, that Greta Thornburg, the young girl from, is she from Sweden? One of the Nordic countries.

23:49 Chris Adams: Oh, yes, one of the Nordics, yeah.

23:49 Michael Kennedy: Climate activist. She was voted, or made, the Time Person of the Year, which is pretty interesting. So that, I think, kind of speaks to a little bit of, people are starting to pay attention.

23:49 Chris Adams: Absolutely. She's so, so cool. I'm so, so pleased and I find this child inspiring. I think we need to be able to be prepared to be able to say, "Yeah, the actions of these people." and them having that kind of moral clarity and consistency I think is really, really inspiring for the rest of us. And we don't all need to be Greta, but I think there are, that the things she asks us to do, were basically, "Hey, I'm a kid, adults, can you pay attention to the science and do something with this?" and basically act like adults. I think that's something that we can respond to. And I think that that speaks to a part of us, which I feel that we, if we look inside ourselves we can answer and work in a kind of responsible kind of authentic way. So yeah, it's really, really nice to see that. And I think that we need people like that to be reminding us of what our responsibilities are as adults are really.

23:49 Michael Kennedy: Yeah, absolutely. So let's bring this back to software, right? That's why we're here talking about this because as software developers or people that use computing in significant ways there's actually a lot of concrete stuff that we can do.

23:49 Chris Adams: Absolutely.

23:49 Michael Kennedy: Code runs everywhere, code runs on our phones, code runs on our laptops. But a lot of code, more than people realize, I think, runs on data centers.

23:49 Chris Adams: Yes!

23:49 Michael Kennedy: And so there's an interesting stat that I got from Forbes. I think this is, yeah, this is only for the U.S. but the U.S. data centers use 90 billion kilowatt hours of electricity a year, which is roughly equivalent to 34 giant coal-powered plants. And I think this is 3% of all, either energy or electricity consumption in the United States. Yeah, total electricity, the 3%.

23:49 Chris Adams: Okay, so these numbers actually feel...

23:49 Michael Kennedy: Is this maybe low?

23:49 Chris Adams: No, these numbers are actually... Yeah, I mean I was, so this is, you get a number of different estimates for this ranging from like 200 gigawatts, which I think is a billion kilowatt. A hundred gig in a gigawatts. Oh, 200 gigawatts. It kind of ranges. The estimates vary depending on who you look at.

23:49 Michael Kennedy: Right, does just the data center inside a company count or maybe only public data centers, or what do they count, right? It could really vary on who they're counting there.

23:49 Chris Adams: Yeah, so it's kind of mind blowing, right? I was at... In my role as someone working with the Green Web foundation, I ended up at this event which was organized, at a workshop organized by the European commission on how they're going to do green public procurement. Because in Europe they spend something in the region of 45 billion euros each year on technology, and they want to do that in a fashion which is more in line with the science and in line with the fact that they have basically declared a climate emergency as the block of Europe. Because they too have realized that the internet runs on electricity and servers run on electricity. They want to work out how to do this. And even inside that when you've got people from Amazon, Google, Microsoft, all of these places, they are still trying to do like, saying, "Oh we need a definition of cloud that we can use across this. We need a definition of what data centers are." And it's kind of bonkers that you do have... You have this ambiguity. And when you see these numbers, of lots of the studies, they will often use slightly different definitions of the same thing. Like, does it include Bitcoin mining? Does it not? Is that a data center, is it not a data center? Because that kind of power profile is different to how you might use something else. So it's a, long story short, it's basically these numbers you shared, they're not wildly out, and the figures that people tend to use for data centers and the internet in general, or a kind of tech is between 2% and 4% of, well, between 1% and 4% of all CO2 emissions. So that's in the same ballpark figure as all of shipping or all of aviation.

23:49 Michael Kennedy: Yeah, exactly. All flying is like 2.5% or something like that, yeah.

23:49 Chris Adams: Or Germany. So these are significant numbers. And just for a streaming video for example, the figures we see from a recent report by the Shift Project, they say, "Well, all streaming video, that's about the same carbon footprint as Spain." The country of Spain.

23:49 Michael Kennedy: And it's cats. It's viral cat videos, right? No, of course, not all of it.

23:49 Chris Adams: Actually, no, it's crazy. Like a quarter of that is porn, alright? So, a quarter of the...

23:49 Michael Kennedy: Oh, my gosh!

23:49 Chris Adams: Of Spain is porn, right? And it's just, yeah, the numbers are mind blowing when you look at this because we tend not to really be thinking about this kind of stuff, because we are so, because we have done such a good job of abstracting the eventual kind of implementation details of whatever is it we're doing that we're not aware of this stuff.

23:49 Michael Kennedy: One of the feelings that I have that is a realization that blows my mind is I can go sit in a coffee shop or somewhere with my MacBook and I have a pretty high-end MacBook, but even if it was a MacBook Air, I could sit there and I could write my code, I could have a little database server running and get the web app working and whatnot and then I push a button and it goes out and runs on incredible high-end servers in massive data centers with its own database server and the web front end. And it's almost like a disconnect from me that I can work on these little tiny devices and I push a button and then it's on this great big thing. And of course, I mean, it could scale huge, right? I could scale that out to a hundred servers if for some reason that was a thing. And it's really easy to disconnect that from your mind to, I'm actually running a hundred desktop-type things when I just push deploy, right?

23:49 Chris Adams: Well, yeah, you're right. But it's worth being aware that in many cases, that when you put something into that cloud, for example, over the last, say, few years, like at least five years, actual energy usage that was reported by the IEA, the International Energy Agency, they've generally said that emissions have been... So energy use has roughly been pretty stable in America, at least largely because there's been this massive growth or move from lots and lots of relatively inefficient data centers to the Cloud.

23:49 Michael Kennedy: True.

23:49 Chris Adams: The Cloud is massively more efficient in cases...

23:49 Michael Kennedy: A virtual machine and it's sharing that CPU and that hardware with many other virtual machines rather than having a hardware device in my own company's data center. This portion of Talk Python to Me is brought to you by Datadog. Datadog is a monitoring and analytics platform that unifies metrics, logs and distributed traces from your Python applications. Datadog's tracing client, auto instruments, popular frameworks and libraries such as Django, Flask, PostgreSQL and Async IO, so you can quickly get deep visibility into your applications. Place requests across service boundaries, correlate traces with logs and metrics, and plot your application architecture with the service map. Get started today. Sign up for our free trial at talkpython.fm/datadog and Datadog will send you a free tee-shirt.

23:49 Chris Adams: There is also a flip side to this. And, there's a guy... So, there's a gentleman called William Stanley Jevons. 200 years ago, he observed the same impact that we see now when he was looking at how steam engines were becoming more and more efficient. They were like, every individual new generation of steam engine uses much less coal for the same amount of work. So that's going to result in a kind of fall in coal usage by the industry, right? And it turned out not to be the case. It turned out to be that, it was called William, the Jevons paradox is the phrase. We might also call it the rebound effect in some cases, where as you make something more efficient, you end up seeing more use of it. So the total amount grows even higher. If you want to sound really posh, you can call it the Khazzoom-Brookes Postulate, and that's the one for Wikipedia, right? And that sounds really, really posh. But basically, as things get more efficient, we end up using them more, which can often result in greater emissions if we do not find a way to decouple the emissions. Basically there's a line and you need to vet it. There's a degree at which it ends up with more emissions or no emissions. And this is kind of why tech in many cases has been presented as one of the kind of wonderful hope for the future, 'cause if we could only find a way to make better use of the tools we have, often through technology, then there's a chance that we could kind of steer this economy away from the iceberg and into something more like, I don't know, Star Trek than Mad Max, I suppose.

23:49 Michael Kennedy: Yeah, yeah, I mean, let's go... Yeah, let's definitely stay away from Mad Max. Now you've given a couple of presentations on this and I'll link to those in the show notes. You've got the...

23:49 Chris Adams: Yes.

23:49 Michael Kennedy: Slides up and those are really helpful, with cool pictures. One company that you called out that I use for a credit card, when people buy courses on my platform, it goes through Stripe. A company called out Stripe for being a good citizen on how they report and account for their emissions. Could you talk to that real quick?

23:49 Chris Adams: Yes. I'm worried about kind of diving too deeply into this, and it's probably useful to have the slide that we are going to refer to, but if an organization is going to talk about carbon or talk about being kind of environmentally responsible, if they're not really talking about scoped emissions, then they're kind of doing it wrong, alright? Because this is generally considered the sensible way to talk about it. And you have three main kinds of scopes, which are generally kind of considered ways to account for emissions from different things you do. So scope one might be emissions from you burning fossil fuels yourself.

23:49 Michael Kennedy: I've burned a hundred gallons of gas, so that's my...

23:49 Chris Adams: Yes.

23:49 Michael Kennedy: My carbon footprint.

23:49 Chris Adams: Yeah. Yeah, the example I use in talks is coffee because lots of us like coffee. So, if you burn gas to heat up a kettle to make coffee, that's like scope one emissions, right? Scope two is emissions from electricity that you use. So that might be someone else miles away burning coal so that you can use a kettle to heat up some water to make coffee, alright? So companies like, say, Amazon and Google who tend to use a lot of electricity, they're going to have very, very high scope two emissions in most cases, right?

23:49 Michael Kennedy: 'Cause something's lost on the wire. There's some inefficiencies...

23:49 Chris Adams: Right.

23:49 Michael Kennedy: At the plant, all that kind of stuff, right.

23:49 Chris Adams: Yeah, absolutely. And that kind of speaks to the fact that a lot of us don't tend to, we don't physically burn coal ourselves to power a computer, but someone's burning it somewhere in another hearth, right? So in many cases that might be kind of those large companies' scope two emissions and we wouldn't really have very high scope one emissions ourselves in many cases. But scope three is the kind of biggest source of emissions for most of us. And the slide that I think you're referring to shows Stripe having quite low scope one and scope two, which makes sense because they are large, large customers of kind of cloud giants. So therefore the scope three is basically... The example I use is, imagine you're walking into Starbucks and paying for a coffee. So, someone somewhere has burned fossil fuels to generate the heat to make that coffee or to make sure you're in a nice warm space. So it's kind of in your supply chain really, that needs to exist for you to make coffee. And for most of us, our emissions are going to be in scope three because we are mostly purchasing services and selling services to other people if we're developers rather than, I don't know, miners ourselves, you know?

23:49 Michael Kennedy: Right, right. There's a lot of knock on effects out in three, right? We've got to fund the military who sends a bunch of people to some unstable place, and how much carbon do they spend to just ensure political stability so that then the oil company can send a bunch of machines over there to mine it up and ship it. There's a lot of stuff happening that's not just the carbon captured in that bit of oil.

23:49 Chris Adams: Yes!

23:49 Michael Kennedy: We should think about this for basically our code as well, is what you're saying.

23:49 Chris Adams: Yeah, I mean, as developers, I think the concept that we have a dependency chain to the stuff we do shouldn't be an alien one. We're continually using dependencies from lots of other people, and this is how people in the kind of climate world think about dependency change really, because this is something that we're used to using anyway. If we have a requirements.txt file, then there's something happening there that we're aware of. So intuitively it should be something that we can kind of internalize as a concept, really. It's just that...

23:49 Michael Kennedy: For sure.

23:49 Chris Adams: We tend not to have to quantify this.

23:49 Michael Kennedy: Yeah, I mean that was sort of what my example of the coffee shop push toy was. It's kind of like, it's so easy to, it stops here, you know what I mean? But it really, that's just the beginning. To be concrete, you have some interesting mental models that you talk about that help bring this and thinking about it and some tools we're going to talk about some steps. So you have Platform, which is the infrastructure that you run, right? This is, I guess, the cloud directly a lot of times. Packets, which is the stuff that flows between you and your other services, or people who are consuming them, and then process about how your organization works, which is maybe more tangential to that. So, let's start a platform.

23:49 Chris Adams: Yeah, okay. So I've tried to take this concept of scopes and find some kind of comparison for what you might do as a developer or as a kind of tech professional because it feels like speaking about skips is often quite abstract for a lot of us. And, it kind of makes sense to talk about things we would use ourselves. So I talk about packets because in many cases a lot of us that might be infrastructure that you might use yourself or the servers that you run. And when you have something like that you've got kind of levers. So one lever might be how you provision the infrastructure that you use to kind of meet demand. And we could go back to examples where you used to kind of physically provision servers in the rack and then you just hope that you and your provision for the most possible load, because it's going to be really hard to scale that up, right?

23:49 Michael Kennedy: Right, especially if you have to buy machines, and like you said, put them in the rack. If on Fridays you have to handle a hundred concurrent requests, but most times it's 10, you buy machines for 120 and you run them all the time, probably.

23:49 Chris Adams: Yeah, exactly. And most of the time that results in you... Because computers don't scale all the way down, you're basically burning loads of money but it turns out that because computers use fossil fuels a lot of the time, they're burning lots of fossil, there are unintended consequences to that, which should result in lots and lots of CO2 emissions. And yeah, you have that. And as we've got better at provisioning, or if you are a kind of developer, the way you might provision might have an impact. So rather than having a giant, giant physical server, one thing you might do instead is have some kind of scaling thing or working with VMs or Docker or whatever thing that makes it possible to kind of scale that way. That's one way.

23:49 Michael Kennedy: Right, yeah. The Kubernetes, it's pretty easy for them.

23:49 Chris Adams: Yeah!

23:49 Michael Kennedy: It also seems to me, I would like to hear your thoughts on this, that if you're purchasing VMs in the cloud, I know there's other stuff like serverless and so on that kind of does this automatically. But if you're, say purchasing, I guess even Docker, but if you're purchasing and say servers and virtual machines, you can buy them or provision them with dedicated CPUs so that you're guaranteed to have that CPU core available for you. Or you can do it with shared. And I feel a little bit like if you go and buy the dedicated server, fully dedicated CPU machine, you're kind of locking out that thing to run all the time, right? 'Cause you've got 12 cores, only 12 people can buy dedicated machines on that, and that's it. Whereas if you're in the more floating kind, you might suffer a little bit in performance, but it's definitely going to scale down massively when it's not busy because it's going to be able to share that with other VMs. What do you think?

23:49 Chris Adams: It's a bit like, okay, let's just use the example of cars, right? I could buy, if I run a business, I could have like 12 cars, or I could pay for a taxi service, which is a scale of the amount of things I'm using any one point, right? Yes, you having to purchase exclusive use of something will do that. In many cases we will make that decision. But in many there will be trade offs that we make and there'll be consequences of us doing that kind of stuff and it's very difficult to really kind of give specific guidance on this because it's going to rely so much on context. And this is why I said, in many cases, we kind of need to be able to understand the full cost of what we do and understand that, and be able to make those judgements in an informed way because in many cases there is an argument for using something like, say, serverless where the kind of economics and the incentives are aligned much, much better.

23:49 Michael Kennedy: Right. Serverless, it doesn't even run at all if it's idle, right? It only processes the demand.

23:49 Chris Adams: Yes. So, that's good in some ways. I mean, to be honest, the amount of... The kind of energy savings that come from that is quite difficult to really quantify because most of the large organizations that do provide this tend not to be prepared to share these numbers. And if there are groups who can share these numbers, it will be fantastic for the good of science because even the professors say, "We don't know Rita." No one knows that. And it's rare...

23:49 Michael Kennedy: 'Cause it's all these giant corporate places that the whole data center infrastructure, that's a huge area of competitive advantage. They're making their own hardware. They're doing all sorts of crazy stuff around cooling and energy. I mean, they don't want to share that. Why would they want to share that, right?

23:49 Chris Adams: And you see this now even when, absolutely. And even down to just how long you hold onto servers in the first place, you might assume that, in many cases, we might assume a server, which takes a lot of energy to turn into a server, 'cause remember, chips are sand initially, right? There's a lot of energy from turning sand into a server, all the chips right there. We don't really think about it until, it's not something you have to face. But yeah, there's going to be, and remember, 'cause if energy's coming from fossil fuels and it doesn't need to but often does, then that's where there're going to be lots of emissions. If you have a server which only lasts, if people are swapping out servers every year versus every three years, that's going to have an impact on the calculations that you actually might have. So yes, you're absolutely right there.

23:49 Michael Kennedy: So one question I have about serverless. On the face value, it seems, obviously that's going to be better than VMs. Let's say the shared kind, right? I mean the dedicated ones clearly are just constantly running. But it also seems to me like each individual request might take a lot more energy because it's got to maybe start up some kind of Docker. It's not just running a few lines of code in an already running process. It's every one of those is kind of a fresh go at it, a new environment. So even though you can scale infinitely, 'cause you could hit 100,000 servers if you hit that hard enough, right? But that may per request cost more. There's just an interesting trade off there. I was thinking about it as we were talking about this.

23:49 Chris Adams: Yeah, I mean this is exactly what you see with servers anyway, right? We know that if you're going to buy a physical server then when when Amazon, when various, when kind of Cloud computing products came out in the first case, people say, "Hey why would I spend money on Cloud when I can buy a server to give me the same resources over a longer period for less money?" You're paying for the flexibility and you're paying for the fact that you don't have a giant great server to kind of decommission at the end of three or five years or something. So in most cases there will be a PIA per request trade off. But with the idea being that you pay slightly more per request for the flexibility and the efficiency at a kind of systemic level, I suppose. But once again, who knows for sure?

23:49 Michael Kennedy: Yeah, who knows? I would guess that serverless is more efficient in terms of energy in general, but I don't really know. Alright, so one thing I do want to talk about in this area is, you have some tools. At each one of these three levels, you have tools in the Python toolbox, stuff that you can run or things you can do or libraries you can use. So maybe tell us about the ones that you have for this, and I'll tell you about a few that I came up with as well.

23:49 Chris Adams: Yeah, okay. So basically any tool that can track the amount of CPU usage you're using can also give you an idea, because energy uses fossil fuels, what the climate impacts of a lot of this stuff will actually be. There is now a moral argument for basically optimizing your code, because...

23:49 Michael Kennedy: Great!

23:49 Chris Adams: So, that is good news for developers who like performance, right?

23:49 Michael Kennedy: Right. You already want fast code now because it means you can, obviously users want it. 'Cause it's faster, or software feels better and more professional. You want it 'cause it's fewer machines to manage. It costs less. The data centers want it. And then of course, that's all aligned up with CO2 emissions. You found this thing called energy-usage, which is an NPM tool, right, you can run?

23:49 Chris Adams: This is a Python...

23:49 Michael Kennedy: Oh, Python, okay. Another one down later, that's NPM, right?

23:49 Chris Adams: Yeah, so this was designed specifically to address the... I think it was designed as a response to, but basically revelations amongst people who are working with, say, AI that the kind of, you know, we speak about Moore's law, it doubles every 18 months, right? We see some kind of changing impacts there. I think a year and a half ago, a paper was released showing that the kind of average amount of compute used to achieve the various kind of goals or breakthroughs with AI is doubling every three and a half months, right? And, I think over a two year period, please don't, I'll share that link specifically. But because of this doubling feature, it basically results in massively more energy use. So the point that something that might double seven times in the set period, if you're looking at a three and a half month doubling period compared to 18 months, it's like 200x or 200,000x versus 7x. So you're seeing a big increase. And this was generated, this Python module is basically a tool to allow you to kind of profile some code. It'll give you an idea of the emissions, the energy usage for that by kind of reading some of the energy usage stuff from, I think, from some Intel processes, share this, and then they converted that to the CO2 per kilowatt hour, for example.

23:49 Michael Kennedy: Right. And then it ties it back to where you're actually located even.

23:49 Chris Adams: Yeah, absolutely, that's what it does. And this was designed for people working with machine learning to get an idea of what algorithms are going to have an impact, so that you could make these decisions upfront or be aware of the trade offs of using one thing over another. Because as I understand it, and I'm not a data scientist, different machine learning tools or approaches use wildly different amounts of compute. And this was designed as a tool to show you that. And there's also a whole kind of syllabus tied to this, 'cause this was shared by a professor that I follow on Twitter, when I saw it. I've totally forgot her, the woman's name who did it. And I'm really embarrassed for forgetting her name, but she's been sharing a load of really interesting stuff on this and this was work from, I think, a group called Climate Change AI who invested a bunch of time into this. So yeah, that's one thing that you've got.

23:49 Michael Kennedy: That's really interesting. I'm trying to look up her name as well, but I couldn't find either. So another thing, and this platform part is, like we just mentioned right before, is faster code is more efficient code, means fewer servers, means smaller servers and so on. And there's just a bunch of techniques that you can apply to your code, right? Like if...

23:49 Chris Adams: Yes!

23:49 Michael Kennedy: You use a database, make sure you're using an index. It's not just faster, it uses less energy, right? If it responds in 10 milliseconds versus a second, that is a whole lot less work it's doing. Not always, but most of the time when your code is stuck or waiting, it's something in the chain is cranking as hard as it can to get back to you. Maybe if you call it a remote service and there's like a hundred millisecond ping time, that's different, but if it's not far away, the delay is sort of computation time for something, I would suspect.

23:49 Chris Adams: Yeah. So, I mean, some of the concrete examples that I think that might be of some use here would be, and you could kind of like take a leaf out of some of the nodes book, right? When you have things like Async, if you've got a way of working where you're not blocking and you're able to let seven other requests, then theoretically you don't need to be running quite so many machines to do the same amount of work.

23:49 Michael Kennedy: Absolutely. If you're using the async and await-based frameworks like Sanic or some of those, yeah.

23:49 Chris Adams: Yeah, so there are some ways that you can, basically anything that tend to improve performance, because you're generally using fewer resources to achieve the same kind of result, it makes a lot of sense. So yeah, you already know these techniques in many cases, if you are working with Python for example, and some of the things are directly applicable.

23:49 Michael Kennedy: Right, and sometimes people don't bother because it's not slow enough. If you have a pretty busy webpage that loads in a hundred milliseconds but the load is not so high, it's still fast enough, right? You don't need to necessarily optimize it. But if you could get it down to 25, it would use a quarter of the energy, right? So profile your code and see where it's at, and just put that as one of the trade-offs you think about as you build code and care about it.

23:49 Chris Adams: Yeah, and this partly, this is a nice kind of, takes us back to the kind of platform package process thing that I was talking about before. So I found platform was a useful thing to talk about, and we've been doing some work with an agency. Actually there's a group called the Ponopoly, they're a kind of transformation agency in the U.K., and we did some work as the Green Web Foundation to actually help them think about how they build, run digital projects and we started looking at some of their own projects. And we found that the platform part was quite significant chunk from, at least, one of the projects they're working on. But there are also other leverage points they had the packets part and the process stuff.

23:49 Michael Kennedy: Yeah, yeah, yeah, let's talk about packets, 'cause that's the way harder for us to understand how we pull those levers. I can choose the type of server I get, I write the code that runs. I could decide serverless or virtual servers, but I can't decide how my packets get from my server in New York to you over where you are, right? I can't control that part of the world, or can I?

23:49 Chris Adams: No. Well, okay so there's a dream we have. Yeah, there's a dream, 'cause if you actually look into the networks, there seems like BGP which control how packets get routed around and if you had knowledge about which kind of parts of the internet are run on green power, then in the wonderful world, in a perfect world you might have some kind of green BGP that knows and favors the greener nodes more than the other nodes.

23:49 Michael Kennedy: Right, not just use latency or something like that. But until this one gets bad, we're going to flow through this part of the world because this is the best possible path in terms of CO2 to get this from America to Europe or something.

23:49 Chris Adams: Well yeah, so there is... I mean this is one of the reasons we, the Green Web Foundation, we've started releasing open data sets in the hope that someone might take this idea and do something cool with it because, so we've got, we're working on a thing called "IP to Green," which will basically, and there's another thing called Green Trace, where we're basically building trace fruit that hops and shows you whether hops are green or not green based on what the information that we have available to ourselves to make something that is possible. But this is way in the future because we're quite a small group and we we're at the kind of, "wouldn't it be cool if" stage at the moment. But if anyone is interested in doing something like this, I would love to chat about it in more detail. But until then, yeah, you're right. Because you don't have direct control over the internet, and to be honest, for many of us that's a feature, and I think is a feature, because we root around lots of things and by treating censorship like damage, for example, it's good, but it means that because you can't control things directly, you have to control things indirectly. So you might resort to other techniques that we already have.

23:49 Michael Kennedy: Yeah, and there are a bunch. So there's two, let's start with the projects. There's a project from Google called Lighthouse. And the idea is it measures the effective user-oriented performance of your web application. And I've spoken about Lighthouse a little bit before. I came across this and I thought, my sites are super fast. If you go into the web logs and you look at it, it says it's sending the response out the door in 10, 15 milliseconds. And I thought, well how much more can I improve over 10 milliseconds? No one is going to perceive that, whatever. I'll throw it in here and let's just see how it does. I threw it in there and it said, "Your site is average to slow." And I thought, what is this thing talking about? There's no, what is it doing? And it considers all these different things that the user perceives. And I spent days rebuilding all my sites so I can get it up now to almost a hundred. Sometimes on a good day I can get it to hit a hundred out of a hundred, but the idea is it has very concrete steps. And it says you should do things like, You should resize this image to exactly the size that's being displayed instead of shipping a huge one and letting the client do it. You should use gzip on your stuff you're exchanging, on your HTML and your CSS. You should use really proper caching. All of these things are good, and they're all perceived by the user to be awesome. So if I have, a 100K of CSS, maybe not that much, but a lot of CSS and a lot of JavaScript, if you only request it once, but you hit the site a hundred times rather than over and over and over again, that is a huge amount of traffic you're alleviating, right? So this tool actually is really good for controlling what you put on the wire.

23:49 Chris Adams: This is one of the levers that you do have. And what we decided to do was basically fork this. So we took the Lighthouse, forked it, made it refer to say which parts of the websites were green and we called it Greenhouse. So it's a plugin. So anywhere that you would use Lighthouse you can use this to get an idea of which parts of your supply chain or your dependency chain are running on renewable power. And the thing that we were also doing with this is to convert some of, we haven't implemented this yet, but we actually have the data out there and we've been doing it with some consulting clients. So basically take this and give people rough ideas of the CO2 emissions from doing this. But absolutely. Basically green websites are usually good websites because they're fast and they make good use of the resources that we do already have. And once again, we already know how to do so much of this and there are clear steps that you can actually follow. So yeah, this is kind of what we did and this is what I've spoken about a few places before. You already have a lot of the tooling already to do this. And in many cases, depending on what you're building, this may be a more effective place to spend your time than say on, say, the platform part, depending on how well-optimized your website is or what it's for. And this is why it's important for us as professionals to understand these things and know where we were going to spend the limited amounts of time that we do have to improve the full end-to-end experience for end-users.

23:49 Michael Kennedy: Right, and it can be incredibly simple things like turning on caching and just, "Oh, I just, I didn't even realize that we had forgot to turn on caching for these static files, we're turning on gzip." Another one is optimizing images. And I talked about resizing them to the right size, but there's a bunch of cool programs. So one I used called ImageOptim, had a bad name, but I'll link to it, but basically you grab a folder, you can just grab your whole website and throw it on there and it'll traverse it hierarchically to find all the images and it applies about 10 different algorithms to shrink it, and it'll shrink it like 50% without even losing any quality, it's ridiculous.

23:49 Chris Adams: Yes. So, there's a woman called, Hannah... Oh God, I forget. So, she's on Twitter as Hanna OP, and I'll share the link to her. She shared a really good deck all about this information and it basically explains all these things. There's loads of tools out there that we can use to have a measurable improvement in this stuff here. And in many cases, I'm glad that you mentioned the compression thing because when Netflix did this, they basically halved the bandwidth bill for a bunch of the projects that implemented this. Because if you just forgot to kind of switch on, compress or gzip, there's something on the server. And there's actually some opensource plugins to existing servers that would do a bunch of this stuff for you on the fly. If you look for the, I think Google Pagespeed plugins, you'll see some of this stuff for Apache and for Nginx. So there's already stuff out there and there are also services like Cloudinary that will do this stuff. But again, it's worth remembering that, useful to know where the impact is going to be because depending on the usage profile of what you do, this might not be the most effective place to invest your time if you're going to be thinking about, I guess, the kind of climate impacts of the way we work.

23:49 Michael Kennedy: Yeah, it's something as simple as throwing your images into one of these optimizers, that doesn't take any thought, right? You're not like, "Well, if I do this, I might break something." As long as the algorithms are lossless, you really don't have to think at all, you just do it. But if they're served millions of times, it's a big deal.

23:49 Chris Adams: Yes, absolutely.

23:49 Michael Kennedy: Yeah, there's a lot, I guess the point I'm trying to make is there's a lot of low hanging fruit here and the tools that you talked about, Lighthouse, which is a plugin for Chrome or Google Pagespeed, which I'm linking to in the show notes is the online version, and then the Greenhouse fork of it that you talked about, yeah.

23:49 Chris Adams: So that was the thing that we have. But there's other things as well. There's one called sitespeed.io, which is basically like a Docker container. You can literally, if you can run Docker, you run Docker, and then point a URL at it, and it'll give you a report of all this stuff automatically. I've referred to some things from Google, but there are other tools around there that will help that you can use. And the nice thing that I've seen with Sitespeed that I really like is that they can give you, it talks to a Grafana and Graphite so you can kind of start charting and graphing this stuff, so you can see changes. And I believe there are now some GitHub actions. So every single time you make a change, you can see whether it's going to be an improvement or a regression on what you had previously.

23:49 Michael Kennedy: Yeah, yeah, very neat. Alright, so there's a lot more stuff we could talk about in the packet side, but let's, just for the sake of time, let's move on to process, which is more about how your, possibly tech company, possibly other company where you do tech stuff, works in more general, right?

23:49 Chris Adams: Yeah. And this is the one which, in many cases, is probably some of the biggest leverage points available to you, but they're often some of the harder ones to actually start because they often rely on organizational changes. It's going to be stuff like, okay, how we think about travel or how we work. I mean, when you look at, say the report from, if you look Apple sustainability report, right? I mean, I've shared a link to it. There's a few things that are really interesting. So because I did, in the talk that I gave recently, or one of the talks that I've been doing recently, is just showing the emissions from large companies that we know and admire. So Amazon, emissions from Amazon, are roughly same size as Finland for 2018, right? The country of Finland has basically the same emissions as Amazon, according to their report. Google is about the same footprint as Liberia. That's a very small country in Africa. And Apple's figures were for The Gambia, right? So that's what, I think, 0.6 million tons of emissions, if you don't include their hardware like making of iPhones and stuff like that. If you include that, it's basically Mongolia. So the country of Mongolia, all of the output is basically all the iPhones and all the things we have there. But if you look at just the non-electronics part, most of the emissions, like half of that, half of the emissions from Apple is from business travel and a more than a third comes from employee commuting. 'Cause in many cases a lot of, if you look at Apple's wonderful campus that everyone has to drive to, you've just, yes, it's cool that you've got a nice grand campus and stuff, but now if everyone has to drive there, there's all these emissions associated with it.

23:49 Michael Kennedy: And it's right in the middle of greater San Francisco, which is notoriously gridlocked, right? There's just tons of driving and what not there. I mean, from that perspective they could put it somewhere more remote and that would be better 'cause people could live near it. But of course, they're not in San Francisco or Silicon Valley, I mean, yeah.

23:49 Chris Adams: Yeah. This is the thing, in many cases, in lots of remote friendly companies, there's a very strong environmental argument for it, 'cause in addition to it being...

23:49 Michael Kennedy: There's a huge one, yeah, you're right.

23:49 Chris Adams: I mean we were basically in the process of releasing a spreadsheet to kind of help you work here, understand the emissions at a project level so you and your team can see where the levers are that you might actually have. Because on some cases when we've looked at some projects, we found that, oh wow, getting rid of the video on the front page had the same impact of all of our commuting over the last year, for example, depending on the scale of the company, right? But in some cases, if you're working where there's loads and loads of driving because someone has like an hour, two hour commute each way, then one of the most most impactful things you can do on a project might just be, yes, we're going to do remote working better because we don't need to be driving. And it has all kinds of nice side effects. I mean, in many cases, if you think about how you work, you can have these other kind of, what people refer to as co-benefits. So, remote work will often make it more accessible to people with kids, for example, or people who might have mobility problems. There's all these things that we can do which also end up making things a bit greener, or just things like thinking about how much we do need to fly, for example.

01:00:22 Michael Kennedy: Right. Could that meeting be in Zoom, or do I have to fly from New York to London to have it in person, right?

01:00:27 Chris Adams: Well yeah, and Microsoft is a good example of this. They have an internal carbon price on top of their flights as a disincentive for them doing this. But also, they've set up a kind of green cloud advocacy kind of group now, and also, this is just few weeks ago. I think it was last week that it became public. But also, one of the people there who was giving a talk at DevRelCon about low-carbon developer relations, like low-CO DevRel, and one thing he was looking at doing is he gets the teams to just track the carbon from what they're doing, or if they're going to fly, make sure they're making use of that flight they're going to do, make the carbon count, essentially. In many cases, there's a big argument for just getting better at remote work. Which is kind of embarrassing that in tech, so many of us aren't all that good at it right.

01:01:14 Michael Kennedy: Yeah, yeah. I did for about 10 years, I did remote work and then finally now I have my own company, I just, but, I've worked from a little office in my house. Hey, it's quite nice once you get used to it. There's a lot of stuff you've got to get used to, right? Like, you don't want distractions around the house to mess things up, you don't want to feel like you're stuck in the office because it's 8:00 p.m. but you're thinking about something else, you've got to work on it, but at the same time, you got to focus and not just watch TV. There's a lot of challenges. But, I think Google can pull this off. They're definitely all better than being in traffic.

01:01:41 Chris Adams: So yeah, this is one example. So, one thing might have been about commuting, but for the model that we've been using for process, the other thing was basically we took into account the efficiency of the building that you're actually in. And in the U.K., and across Europe, there is a directive which basically mandates that every single building has to have an energy certificate, a bit like how bridges might have energy ratings on them. So, you have grades for most buildings. And in the U.K., if you know the kind of zip code or post code for that building, you can get a figure straightaway for the kind of emissions per square meter. So, if you know that most employees have like 10 square meters of space over a year, then you can quickly work out this stuff. And, if someone's working on a year, you can compare that to say, the emissions run from running a service, or using this much electricity, or the emissions from sending things over the wire. You can get an idea of where the impacts might actually be. So, this is why I talk about process. And, I'm just speaking specifically on the project level because there's, we can work a bit more widely as well, and think about the other things that we actually do. But, I'm mindful that you would take more than a single podcast to talk about some of the wider things.

01:02:45 Michael Kennedy: Yeah, absolutely. So, one final thing I do want to talk about is offsetting air travel. Now, flying is not good, but if you do have to fly, we already talked about having a carbon values. But, it's really a good idea, I think, to at least offset it with something you can do. There's places that allow you to do that. It's not perfect, but it's better than doing nothing, right? So...

01:03:05 Chris Adams: Yeah, I agree with... Yeah.

01:03:07 Michael Kennedy: But obviously, less travel is clearly, clearly better. But I did want to point out that there are places that you could go that are pretty good. You talked about atmosfair.de?

01:03:15 Chris Adams: Yeah, so this is a German company that only use one of the, they use what are kind of gold certificates or offsets, which are generally considered to be offsets which do not have unintended harmful consequences, and where the projects that run this are related to at least, I think it's three maybe four of the sustainable development goals. These are kind of one of 17 goals which are generally considered, these are the things we need to be focusing on to make the world a better place. So, that's what these are. Actually, the person I spoke to on... The guy I seen who was saying, he was just doing a talk today at DevRelCon about the different kinds of offsets and what things you have available, and what decisions you need to actually make for that. And, there's one in the, Atmosfair is one example. There's one in America called Terrapass. They generally, if you don't have much time, you cannot avoid travel, it's safer to just go with someone that's the gold standards. And, I've linked to a gentleman who I, I kind of have a lot of time for, a lot of respect for, Kenneth Bowles. He's a consultant and he does need to travel sometimes. And he's basically, he said, "Look, this is my air travel policy." He's got a personal travel policy. Not like company. Companies might have a standard emission policies, this is policy on air travel. He says, "Look, this is what we're going to do, and if I have to travel with them, these are the things that you need to take into account if you want me to be joining you for something." And I feel that there are lots of people who could also do the same thing. And that you could literally just copy and paste this...

01:04:37 Michael Kennedy: Yeah, I'm sure he would be happy and not frustrated if you also adopted his policy verbatim, right? Basically.

01:04:43 Chris Adams: Yeah, I mean...

01:04:44 Michael Kennedy: One of those things he does is say, "I'm going to expense the offset if I have to fly to you." Which is totally reasonable. If I have to travel internationally, it might be $100 offset, but that's part of the bill if you invite me to come because I'm not traveling without them.

01:04:57 Chris Adams: Well, this actually speaks to something which is more, I'm seeing some agencies, some forward-looking agencies doing now, where they basically have their carbon budgets on projects now because if, basically, depending on where you are in the world, and the U.K. does have quite good data on this, you can basically work out direct emissions from say, I don't know, 100K of spend or something like that. So, if you have maybe a project where there's going to be, which'll cost like $200k then it's not a huge leap to say, "We know that there's going to be 100 kilos of carbon emitted per thousand pounds spent, and this is a $20k project, a $200k project, then that might leave us with a budget of..." If we want to be better than average, and we need to be better than average, or improving on what's happening each year to kind of stand a chance of meeting the scary goals we spoke of at the beginning of the year, they say, "Well, we're going to have a carbon budget of 20 tons, so everything we do has to stay inside that budget, and this is a shared responsibility for us and also the client that we're working with."

01:05:50 Michael Kennedy: That's interesting.

01:05:50 Chris Adams: There're some things... Yeah, 'cause this stuff can be quantified, and once you have some numbers like that, in the same way that you have performance budgets for websites, I think you can use budgets like this to help, you can essentially create the incentives to make it easy to have, say, a remote call versus having to fly, or having to travel somewhere. And, I think that without this stuff it's going to be very difficult for us to basically face the challenges that are, that the science dictates. But, we do have the tools and the numbers to actually do this. And I think in many of us, the tech industry is such a rich industry compared to others, and there are so many people with so much professional mobility who are able to basically say, "Look, this is how we're going to work, because..." And, "This is how we chose to come into the industry for this." I think there is a lot to be said for thinking about this and considering it part of just being a responsible professional in technology, to think about these things.

01:06:45 Michael Kennedy: Yeah, well said. One final thought I want to throw out there around this travel stuff. I try to travel less to conferences. I'm going to PyCon this year as I did last year, because it's important and I have to fly to it, right? I went to one other conference this year that I had to fly to, which is Microsoft Ignite in Florida. It was an interesting opportunity that I had and it was worth it. So, I bought offsets for those and it was all fine and good, that's just what I did. Still not my favorite, but whatever. So, one thing I would like to see, though, is that, have conferences make it almost the default to have, not just me do that. The reason I mentioned that conference in Florida by name is they have 30,000 attendees. How many of those people do you think offset their carbon?

01:07:23 Chris Adams: So, this is actually really, absolutely you're right. There's two things which I could share with you which I think might be interesting for you. So, I did some work, I helped organize a conference called MadCap where we basically had a climate sponsor specifically to account for the fact that we knew that some people were, we made the decision to run a conference and cause people to be flying here, and we chose the venue, so therefore we felt like it's on us to be accounting for this stuff. And if you kind of just shift it onto the end user, that kind of is a bit unfair in many cases because you often are already making people to pay for something, and if you budget for this as part of just how you work, then it makes a lot more sense. And there are more group organizations doing this. But the thing that we've done is, we actually hired some consultants to help us work out the emissions associated with that conference, and we also, we're in the process of releasing a report which has all this stuff, where we've got the numbers for this and we can see what the trade-offs were so that other people can take this information. And, there's also a really, really cool Django project called Open Footprint, which is exactly related to this kind of stuff.

01:08:25 Michael Kennedy: Absolutely.

01:08:26 Chris Adams: There's a guy called Silva. Oh, I totally forgot his surname. He's on Twitter as Silvaness. But, he's been building, him and his team, they've been building Open Footprint, which is a conference carbon footprint calculation tool to allow you to see what the impact of these things would actually be. And, for a 600-person conference, it was about, I think we spent, we raised $5k for that. So, some of it was education. Some of it was kind of offsetting, is what we used, we used for this. But, I think it should be a norm if we're going to be responsible people organizing these events.

01:08:55 Michael Kennedy: Sure, absolutely. And, it would be ideal if the people putting on the conference did it. I can imagine there's sometimes smaller conferences or something, and they just feel like they're barely able to even fund this thing, whatnot. So, if they can't do that, maybe they could have a little checkbox on the register. It's $230 to join this conference and it has a little pre-checked, maybe even pre-check it, carbon offset, $30, I'm flying, or something like that. And, you can uncheck it, but if it's pre-checked, then you just hit Go. How many people would just expense that back to their company, right? It seems like such a small thing that would make a huge difference. If you have, say, 30,000 people going to your conference, all of a sudden that's tremendous.

01:09:30 Chris Adams: So, ROSSComf did something really interesting in this field. So, ROSSComf E.U., they had an event in Barcelona. And, because Europe has pretty good rail links, they basically said, Okay, we're running this conference, if you want to get here by train, and we'd really, really support you doing that if you can, there's an Interrail pass, and here's a way that you can get here by train. And it's a different way of traveling because Interrail is basically, it's a bit like, you pay for a set amount to be able to take any train, or almost any train, over a set period of like a week or so, or a month. And, I did the same thing as an experiment, in low-carbon developer relations, by having a two-month Interrail pass to travel around all little bits of Western Europe. And they said, "Here's how to do this, these are the places you might want to visit along the way as part of this process." So, there are groups who do do this, and they think of the travel as part of the conference itself. And, I've had people talking about having a Sprint bus where people kind of work and code on something together.

01:10:27 Michael Kennedy: Oh, that's cool.

01:10:27 Chris Adams: Yeah! There's loads of ideas. We just need to be more creative about this if we're going to have events where people physically need to be around. And, that's totally okay, as long as we think about the full cost of this stuff.

01:10:38 Michael Kennedy: Right. Well, I already told you I lived in Germany for a year and I'm very jealous of the rail system that you all have over there. So yeah, let's leave it at that. But yeah, I think even things like conferences, tech conferences, could do a lot. Even just little default, just check boxes like, "Hey, we're going to donate, you're paying $30 to send some money here, unless you uncheck this when you register." or whatever, right? Give some people some leverage, but make it at least the default option to not make it so impactful, in a negative sense.

01:11:03 Chris Adams: There's a group who are working on, and I'm part of it, There's a group working on a kind of climate code of conduct for conferences to address these kinds of issues. And, I'd really like if people who do have an interest, it'd be really nice to hear from them because there's a bunch of us, there's a group called Climateaction.tech, which I invested a bunch of time working on because I find it useful. Which is basically other professionals who are trying to do this. And, there's a bunch of us trying to figure out how to do events greener. So, if any of this is interesting to you, I'd really recommend A, joining the community that we have, and yeah, let's talk about some of this. Because it's easier to face this stuff as a group and to compare notes all together.

01:11:36 Michael Kennedy: Yeah, absolutely. Alright, well we are over time on this topic, but it was well worth it, it was a fun conversation, Chris. Now, before you get out of here, let me ask you the final two questions. If you were going to write some Python code, try to make it fast and energy efficient, what editor would you use?

01:11:49 Chris Adams: Ooh! I've gone through a number of editors. I started an issue with TextMate ages ago and then I started using Sublime. And then, I kind of started using Vim 'cause I thought that's what cool people should be using and I'm not a proper programmer if I use Vim. And, I tried using Emacs, didn't get much luck. And I quite liked Vim. I find myself, because I do a number of other things as well than just coding, I really am enjoying VS Code, and I'm finding the... Yeah, VS Code is my editor now. It's free, it's well-designed.

01:12:16 Michael Kennedy: Super flexible, all the extensions.

01:12:19 Chris Adams: Yeah, exactly. I'm a big fan of VS Code. It saves me from myself in many cases.

01:12:24 Michael Kennedy: Sweet. Alright, and then, notable Py PI package that you maybe found interesting or is relevant to the conversation?

01:12:31 Chris Adams: I'd probably say... I think the energy-usage one for the A.I. thing I think is really interesting. But otherwise, I think I would really point people to Open Footprint, the open source carbon calculator. Because, we are so good at calculating, we pride ourselves on being informed by data and being able to quantify things. And I think that if we take that kind of approach to other domains and domains like this, it will help us make informed decisions about the things we do as responsible tech professionals.

01:12:59 Michael Kennedy: Right on. Alright, final call to action, people are interested in doing more, giving them some concrete steps, what do you say?

01:13:05 Chris Adams: I think it's important to stress that it's okay to... If you don't know what to do right now. But, I think it's also on you as a professional to invest in developing these skills that we will need to face when we think about the science and what basically children are saying every Friday, because they're scared and they're expecting adults to kind of step up and do something about it. And, I think it's important to learn to invest in thinking systemically. And this information is out there, and there are books and resources out there. I mean, I think that's the key thing that I would call people to do is, be prepared to invest in skills that are maybe outside of your kind of traditional domain of technology and learn to think a bit systemically. And, the thing I would say is that there are lots of other people doing this too, you're not alone. In the groups that I help run, Climateaction.tech, it's basically full of other techies who are trying to figure this stuff out and how to do this. And, a bunch of the messages and the things that I've shared, I've found through really enriching, useful conversations with people who are saying, "What should I do about the fact that I cannot avoid the flying thing?" In fact, the thing with Kenneth, I remember the conversation that it directly informed that. And the conversations with say, Microsoft, saying, "Okay, here's how we're going to do low-carbon developer relations." I remember seeing a conversation there, and the conversation about say, "How do we take in, do something about the fact that A.I. and the use of machine learning is this massive growth in there?" What can we do there? Or, in say the U.K., with the government taking a real kind of ownership on the emissions from their infrastructure, I remember the conversation there saying, "Yeah, we should be doing this." There are people out there trying to solve this. And, it's okay to feel a bit overwhelmed as long... But it's worth remembering, there are people around to solve this. And, it's easier to solve this when there are other people and to share this across organizational boundaries. So yeah, those are the two things. Be prepared to invest and yeah, join the community.

01:14:49 Michael Kennedy: And we can do it. It runs on electricity. We don't have to change everything, we just can change a few things and we'll be good. But we got to do it, right? Thank you Chris for coming on the show and sharing all this, it was super interesting.

01:14:59 Chris Adams: Okay, thank you again Michael.

01:15:01 Michael Kennedy: Yeah, you as well. This has been another episode of Talk Python to Me. Our guest in this episode was Chris Adams, and it's been brought to you by brilliant.org and Datadog. Brilliant.org wants to help you level up your math and science through fun guided problem-solving. Get started for free at talkpython.fm/brilliant. Datadog gives you visibility into the whole system running your code. Visit talkpython.fm/datadog and see what you've been missing. They'll throw in a free tee-shirt. Want to level up your Python? If you're just getting started, try my Python Jumpstart by Building 10 Apps course. Or, if you're looking for something more advanced, check out our new Async course that digs into all the different types of Async programming you can do in Python. And of course, if you're interested in more than one of these, be sure to check out our Everything Bundle. It's like a subscription that never expires. Be sure to subscribe to the show. Open your favorite podcatcher and search for Python. We should be right at the top. You can also find the iTunes feed at /itunes, the Google Play feed at /play, and the direct RSS feed at /rss on talkpython.fm. This is your host, Michael Kennedy. Thanks so much for listening, I really appreciate it. Now, get out there and write some Python code.

Back to show page