Anthony Shaw Profile Banner
Anthony Shaw Profile
Anthony Shaw

@anthonypjshaw

21,709
Followers
2,819
Following
4,155
Media
20,600
Statuses

Python, Cloud and OSS at Microsoft. Author of "CPython Internals". x3 Father, Christian, PSF Fellow, Fellow at Macquarie University @tonybaloney @fosstodon .org

Sydney, Australia
Joined December 2008
Don't wanna be here? Send us removal request.
Pinned Tweet
@anthonypjshaw
Anthony Shaw
3 years
Hey new followers! I'm Anthony 👋 I'm a Python and Open-Source advocate at Microsoft I tweet about: 🐍 Python ⏱️ Python Performance 🗒️ Python Best Practices 🦹‍♂️ Python Security and Testing 🦹‍♂️ Reverse Engineering 🧑‍🔬 Compilers 🧑‍💻 VS Code 🐶 My Dog 🇦🇺 Life in Australia
23
46
937
@anthonypjshaw
Anthony Shaw
2 years
Python 3.10 match statements are faster at pattern matching sequences than equivalent if-statements. MUCH faster. The second functions runs 86% faster than the first. Source:
Tweet media one
31
244
2K
@anthonypjshaw
Anthony Shaw
3 years
Python 3.11 is looking up to 45% faster for creating instances of basic classes and calling methods (most Python code!) 🥳
@methane
methane
3 years
@anthonypjshaw FWIW, Python 3.11.0a6 is significantly faster than 3.10.
Tweet media one
6
32
120
16
188
1K
@anthonypjshaw
Anthony Shaw
4 years
Day 1 at Microsoft- “your job is to work with open source communities to improve @code and Azure for Python users” “this role is flexible, you choose the path” Day 45 at Microsoft- “maybe we should have been more specific.”
Tweet media one
29
73
841
@anthonypjshaw
Anthony Shaw
4 years
So my big news is that in 2021 I’ll be joining Microsoft’s open source advocacy team, focusing on the Python community and Microsoft ecosystem for Python developers. Working with @nnja and lots of other brilliant people. So excited! This Python thing had better be big 🤗
Tweet media one
86
26
763
@anthonypjshaw
Anthony Shaw
4 months
Last night Microsoft did a one off sponsorship of a lot of the open source projects we depend on as a thank you to those maintainers and communities
Tweet media one
8
49
647
@anthonypjshaw
Anthony Shaw
2 years
Python 3.11 also introduces the "Self" type. Great for class methods that return an instance of cls. (e.g. factory methods). They're also great for having type-valid inheritance. super_me is an AdminPerson, even though the class method is described in the base class.
Tweet media one
7
78
595
@anthonypjshaw
Anthony Shaw
5 years
🥳 big announcement! Always wanted to understand how CPython works? Maybe even contribute to the code? Here’s your chance. Announcing the most comprehensive article I’ve ever written. Covering CPython 3.8 from top to bottom 🛶
14
212
577
@anthonypjshaw
Anthony Shaw
3 years
Ok, the last one surprised me. - regular class is 70% faster than dataclass - named tuple is 60% faster than dataclass - regular class is ~30% faster than namedtuple - simple dict is 30% faster than class
Tweet media one
Tweet media two
23
89
555
@anthonypjshaw
Anthony Shaw
4 years
Vim: the original Escape Room
10
69
546
@anthonypjshaw
Anthony Shaw
4 years
📣 my book “CPython Internals” - a deep dive into Python’s inner workings, is FINALLY available for purchase!! It’s Early Access & there’s a discount until Thursday night. 🥳
30
145
540
@anthonypjshaw
Anthony Shaw
2 years
Rejecting my kids’ PRs with required changes is a new level of parenting 🤣
Tweet media one
Tweet media two
11
21
544
@anthonypjshaw
Anthony Shaw
5 years
Look what just arrived in the mail!! It looks fantastic
Tweet media one
27
41
480
@anthonypjshaw
Anthony Shaw
3 years
Facebook just open-sourced their high-performance fork of CPython 3.8 ahead of PyCon 2021, featuring a type-annotations based byte code evaluator, a JIT, a specialised coroutine eval, immutable modules, and a byte code cache.
10
107
481
@anthonypjshaw
Anthony Shaw
2 years
My review of Mastering Python 2nd edition
Tweet media one
15
39
463
@anthonypjshaw
Anthony Shaw
2 years
🙄
Tweet media one
9
62
468
@anthonypjshaw
Anthony Shaw
4 years
First day at Microsoft today! IF anything breaks, it's not my fault.
37
5
458
@anthonypjshaw
Anthony Shaw
2 years
How many times. It’s pronounced “JIT” Hub 🙄
38
32
435
@anthonypjshaw
Anthony Shaw
3 years
Tweet media one
13
65
410
@anthonypjshaw
Anthony Shaw
3 years
Pyjion, a drop-in JIT compiler for Python 3.10 is now v1.0! Pyjion uses the power of the .NET 6 cross-platform JIT compiler to optimize Python code on the fly, with NO changes to your source code required. Linux, macOS, and Windows, x64 and ARM64!
11
95
375
@anthonypjshaw
Anthony Shaw
3 years
Ahh, Open Source.
Tweet media one
5
28
379
@anthonypjshaw
Anthony Shaw
4 years
oh no. no no no no no.
Tweet media one
18
30
366
@anthonypjshaw
Anthony Shaw
9 months
Disable the GIL and enable the JIT! Python 3.13 YOLO edition
Tweet media one
12
74
358
@anthonypjshaw
Anthony Shaw
4 years
After 5 weeks of working at @microsoft my conclusion is that @shanselman is actually an AI. He's present on every platform, how is this possible? 🧐
Tweet media one
21
16
338
@anthonypjshaw
Anthony Shaw
2 years
Furthermore, mapping matching is faster in 3.10 than equivalent Python code. There are some edge cases though but they're being improved on for 3.11 Right function is 47% faster than the Left function (a play on the Chicken, Fox, and Grain riverboat problem)
Tweet media one
8
55
314
@anthonypjshaw
Anthony Shaw
5 years
🎊🥳 big announcement! Will be publishing my first book “CPython Internals” in partnership with @realpython in 2020. Early access late this year. Book is written for 3.8 and have agreed to 2nd edition for 3.9 ✍️
21
50
308
@anthonypjshaw
Anthony Shaw
3 years
🥳After 2 years of work, my book, CPython Internals is now available “in real life”! There’s a video of what’s inside and a walkthrough in this link 👇 33% off til the end of the week.
15
68
303
@anthonypjshaw
Anthony Shaw
4 years
🥳 CPython Internals is officially finished! Digital launch today, paperback (very) soon. Have resolved over 1000 bits of feedback during early access thanks to the thousands of early access readers! big thanks @Jo_Jablonski , Jacob and @dbader_org
Tweet media one
16
69
304
@anthonypjshaw
Anthony Shaw
4 years
Just got the —final— edit of my book in the post in time for my birthday 🥳
Tweet media one
12
25
302
@anthonypjshaw
Anthony Shaw
3 years
@Microsoft It doesn’t matter because the game assigns the mines after the first click so that you can never click on a mine first
Tweet media one
8
22
294
@anthonypjshaw
Anthony Shaw
11 months
Baby steps, but just got a build of CPython 3.13a1+ with "free-threading", (no GIL) with a HTTP network server that runs each request inside a PEP554 sub interpreter. Now I need to get the sub interpreters to load and start an ASGI app, then we'll have lift off 🚀
Tweet media one
11
19
300
@anthonypjshaw
Anthony Shaw
2 years
🧵 on Python Generics. When typing functions, sometimes you want to be flexible. In this example, the function returns the first item in a sequence, or the default value. BUT the typing information about the list is lost 🤔
Tweet media one
12
49
289
@anthonypjshaw
Anthony Shaw
5 years
👀 Yes... the CPython book is happening. Plus because @dbader_org is such a nerd, the book is compiled and rendered via a Docker container with Python scripts 🤪 I've configured a PyCharm environment and FileWatchers so it compiles automatically (check out the top-right!)
Tweet media one
12
47
282
@anthonypjshaw
Anthony Shaw
7 years
This is #PyCon2017
Tweet media one
5
93
280
@anthonypjshaw
Anthony Shaw
8 years
@RealHughJackman it's going to be like Samson having his hair cut. Wolverine becomes a kitten 🐱
3
43
265
@anthonypjshaw
Anthony Shaw
11 months
Ship it!! Was able to get FastAPI running inside PEP554 sub interpreters by using the hypercorn asyncio worker daemons with shared sockets on the —disable-gil build. 1/
Tweet media one
10
39
278
@anthonypjshaw
Anthony Shaw
4 years
Woo we have test prints of the release version! Well, I don’t have any, but Jacob does.
Tweet media one
Tweet media two
Tweet media three
9
31
268
@anthonypjshaw
Anthony Shaw
3 years
I'm sure everyone knows this one, but list comprehensions are faster than for loops. The second function is 20% faster than the first. It's also easier to read!
Tweet media one
11
32
268
@anthonypjshaw
Anthony Shaw
2 years
Commit message "refactoring"
Tweet media one
13
17
268
@anthonypjshaw
Anthony Shaw
6 years
🎉 my first article for @realpython is out! “Getting Started With Testing in Python”. It’s targeted at Python developers who are new to testing. It is a very comprehensive tutorial and a big investment of time. Enjoy!
5
77
240
@anthonypjshaw
Anthony Shaw
5 years
CPython Source code guide to be published next week!!! Updated for 3.8b3. Chrome reckons reading time is 117 minutes 😅
Tweet media one
9
48
227
@anthonypjshaw
Anthony Shaw
5 years
Was thinking that once I’m done with this book I might record a YouTube series for offensive/defensive application security where I show how to hack an application written in Python, why and then how to fix it. Would people be interested in this? It’d probably be 10 part series
14
22
230
@anthonypjshaw
Anthony Shaw
5 months
Spot what's new... 🧐
Tweet media one
16
31
231
@anthonypjshaw
Anthony Shaw
4 years
vscode-pets 0.4.0 is out. You can play fetch with your cat/dog. someone please send help.
4
42
223
@anthonypjshaw
Anthony Shaw
4 years
The Zen of Python says "Errors should never pass silently.". Here is a solution for that problem.
Tweet media one
7
65
221
@anthonypjshaw
Anthony Shaw
2 years
Playing with #PyScript got some very basic demos working. First task this week is to work out how @pythonvscode can consider the contents of the `py-script` tag as Python code and activate the editor
Tweet media one
13
22
224
@anthonypjshaw
Anthony Shaw
3 years
Today I wanted to see if I could make my FastAPI application faster by running it on PyPy. The result? It was 3-4x faster! I've written a blog post on how to deploy PyPy 3.9 into Production using Docker + Azure Container Instances
8
41
222
@anthonypjshaw
Anthony Shaw
3 years
I can’t believe this.
Tweet media one
23
8
218
@anthonypjshaw
Anthony Shaw
3 years
Sam Gross from Facebook has submitted a design proposal on removing CPython's GIL. There's a PoC branch of CPython with it as well The document is worth a read, but interestingly the response from the core developers wasn't "NO"
7
52
215
@anthonypjshaw
Anthony Shaw
3 years
keep seeing the following code: int( x / y ) as a way of doing rounded division in Python, please don't do this x // y is the correct operation. int ( x/y ) is also 2x slower because it does division once, creates a float and then immediately deallocates it after creating an int
5
26
208
@anthonypjshaw
Anthony Shaw
6 years
Finished the first draft of the “complete” review of CPython internals. Here’s a preview. It’s so ridiculously long Twitter made me split the video in 3 parts
5
36
208
@anthonypjshaw
Anthony Shaw
3 years
I gave a talk this week "Visual Studio Code for Python Developers" -- check out the recording. Learn something new about VS Code and Python, or your money back*! *this content is free 😁
2
42
207
@anthonypjshaw
Anthony Shaw
2 years
PyPi is run by a group of (very nice) volunteers. asking people to do something which takes a few seconds every time you upload a package that makes the whole platform more secure for everyone is not controversial. I have to do 20+ hours of training a year to lifeguard for free
4
18
210
@anthonypjshaw
Anthony Shaw
3 years
I hope folks realise how much work goes into a single @realpython article 😰
Tweet media one
6
6
210
@anthonypjshaw
Anthony Shaw
3 years
MSFT quarterly revenue up 19%. Vscode-pets released this quarter. Coincidence? 🤷🏻‍♂️
7
10
206
@anthonypjshaw
Anthony Shaw
4 years
🎉vscode-pets 0.11.0 is out! Featuring a whole new pet due to huge demand.. a RUBBER DUCK 🦆--May or may not help with debugging-- Credit @marcduiker again for the artwork. This duck has style.
Tweet media one
2
38
206
@anthonypjshaw
Anthony Shaw
4 years
Decided Python is too slow. Time to make things faster. What could go wrong? The entire first chapter is on how to write Hello World 🤷🏻‍♂️
Tweet media one
13
12
205
@anthonypjshaw
Anthony Shaw
9 months
New blog post! "Python 3.13 gets a JIT" we look at what this new JIT for Python is about, what a copy-and-patch JIT is (by writing one in Python) and whether this is faster? #python
6
59
201
@anthonypjshaw
Anthony Shaw
4 years
Oh, so in other news, Guido van Rossum is reviewing my CPython Internals book. #NoPressure
4
2
199
@anthonypjshaw
Anthony Shaw
5 years
Here is the table of contents for my CPython Internals book. What's missing? What else would you like to read? What are you looking forward to reading?
Tweet media one
21
37
195
@anthonypjshaw
Anthony Shaw
5 years
People spend so much money on encryption to secure their secrets. Just upload it to SharePoint. Nobody will EVER find it again.
7
31
190
@anthonypjshaw
Anthony Shaw
5 years
Announcement: I’m writing a book on CPython internals. Hopefully published late 2019 or early 2020
9
27
190
@anthonypjshaw
Anthony Shaw
4 years
Why does the UK-EU trade agreement have paragraphs from a 1998 Comp Sci text book in it? Also. They’re sharing DNA and fingerprint data over POP3 (a plain text email protocol)? 😳 the previous page suggests encrypting with SHA1, which my kids could crack..
Tweet media one
4
61
184
@anthonypjshaw
Anthony Shaw
3 years
You know what I’d love to do? Live pair programming with different Python programmers. Then stream it. Would have to think through the format. Think that convincing guests might be tough, would folks watch this? We’d have an app to build/fix/refactor and chat at the same time
43
6
186
@anthonypjshaw
Anthony Shaw
3 years
Back in my day, we didn’t call them microservices, we called them “cron jobs”
5
10
184
@anthonypjshaw
Anthony Shaw
3 years
🥳 My CFP for PyCon US 2022 was accepted. My talk is-- "Write faster Python! Common performance anti-patterns" and it's going to be fun (and controversial 🤣)
10
10
183
@anthonypjshaw
Anthony Shaw
3 years
Maybe we should finally put this book up for sale! Thousands of early-access copies sold, soo much feedback integrated to get to 1st Ed.
Tweet media one
4
16
179
@anthonypjshaw
Anthony Shaw
3 years
Python socks 🧦
Tweet media one
2
10
180
@anthonypjshaw
Anthony Shaw
2 years
Python 3.11 has PEP681, a dataclass_transform decorator for dataclasses. You can use this to annotate your own dataclass implementations to get all the sweet typing information in your IDE. This small patch to @dabeaz 's "dataklass" implementation shows it working in VS Code
Tweet media one
Tweet media two
10
39
174
@anthonypjshaw
Anthony Shaw
3 years
You can now use Python 3.10.0 in GitHub actions! Make sure you put the version number in quotes (long story)
Tweet media one
4
18
171
@anthonypjshaw
Anthony Shaw
5 years
The code comments in the CPython Garbage Collection algorithm are a little unorthadox..
Tweet media one
4
21
166
@anthonypjshaw
Anthony Shaw
2 years
A bit of #mentalhealth sharing. I’ve never talked about this publicly so here goes… I’ve struggled with anxiety and depression on and off for ~15 years. This month is a milestone as I’ve finished transitioning off an SSR I’ve been taking it daily for about 6 years
7
13
165
@anthonypjshaw
Anthony Shaw
3 years
Christmas presents sorted ✅
Tweet media one
9
8
159
@anthonypjshaw
Anthony Shaw
4 years
I choked slightly when this worked. Python 3.9 is evaluating and executing on .NET 5's JIT engine. Importing modules, executing C extensions, all the jazz. Now to get the whole test suite working... 😅
Tweet media one
8
31
159
@anthonypjshaw
Anthony Shaw
3 years
I knew it. This is how it happens. #Copilot
Tweet media one
5
27
155
@anthonypjshaw
Anthony Shaw
2 years
I’ve been promoted to a Principle Cloud Advocate at Microsoft 🥳 the upgrade is an implementation detail; I’m still doing all things Python! #microsoftlife
28
3
162
@anthonypjshaw
Anthony Shaw
1 year
Our team at Microsoft are going to be hiring another Python Developer Advocate very soon. We're looking for content creators (writers, video, or streaming) that are always looking to improve their Python knowledge and share that with others.
21
61
157
@anthonypjshaw
Anthony Shaw
4 years
📽️ The first episode of my new YouTube series "Hacking with Python" is out. In this episode, I show you how to (ab)use SQL Injection lmk what you think
8
33
152
@anthonypjshaw
Anthony Shaw
4 years
I know you're not supposed to ship to production on Friday, but vscode-pets 0.7.0 is out for @code . Featuring a new pet 📎thanks to @marcduiker working tirelessly overnight designing this NB: Clippy will not chase the ball (yet?)
9
18
153
@anthonypjshaw
Anthony Shaw
4 years
I'm planning a YouTube series "Hacking with Python". Episode 1 is on SQL Injection so I made a little sandbox for you to try different techniques (without breaking the law)
12
15
148
@anthonypjshaw
Anthony Shaw
3 years
After spending a few hours on FastAPI + SQLalchemy, this was the pattern I was most comfortable with. Create a SQL model and use a script @tiangolo made to reflect it into a Pydantic class to avoid writing models twice and polluting Pydantic models /w SQLAlchemy attributes
Tweet media one
Tweet media two
6
21
150
@anthonypjshaw
Anthony Shaw
5 years
🥁🥁🥁🥁 Here is what my book looks like! It’s a snake in an X-ray machine 🙌😆 Final draft done in 3 weeks ready for physical copies at @pycon 2020.
Tweet media one
2
20
146
@anthonypjshaw
Anthony Shaw
4 years
90% test coverage
6
19
142
@anthonypjshaw
Anthony Shaw
2 years
I'm not sure what I was expecting by running > pip install nodejs
14
5
142
@anthonypjshaw
Anthony Shaw
4 years
Full Python test suite is running and passing with .NET JIT enabled, which means I can try some third party frameworks and libraries like Django, Flask, Pytest and see what happens.
Tweet media one
6
20
141
@anthonypjshaw
Anthony Shaw
3 years
Python developers are seriously spoilt with Pytest. In C++ land its so frustrating.
7
11
135
@anthonypjshaw
Anthony Shaw
3 years
Loving Python 3.10 so far. All these "little" improvements like suggesting which attribute you meant are going to make life much easier
Tweet media one
8
12
132
@anthonypjshaw
Anthony Shaw
3 years
Building out a demo app with FastAPI + Tortoise ORM. - async by default - db models can be reflected into pydantic models easily - works with asyncpg (Postgres async) and aiosqlite So far, so good. ⭐️⭐️⭐️
Tweet media one
5
18
132
@anthonypjshaw
Anthony Shaw
2 years
Tweet media one
6
3
133
@anthonypjshaw
Anthony Shaw
3 years
Don't know why I keep using the reverse slice to reverse lists [::-1]. There are two better options. In-place reverse method and the builtin reversed() function which returns an iterator.
Tweet media one
11
19
130
@anthonypjshaw
Anthony Shaw
3 years
Running my performance linter over the Azure Functions Python worker code to see whether it can find improvements. It came back and said that "os.path.join" and "os.path.exists" are loop-invariant and should be moved/refactored. Why? Well...
Tweet media one
4
15
132
@anthonypjshaw
Anthony Shaw
3 years
Discovered this really handy pdb function this week. Put it in your except clause and it'll enter PDB console when an unhandled exception is caught. It stops at the frame that was executing.
Tweet media one
4
18
129
@anthonypjshaw
Anthony Shaw
4 years
Testing out PEP622 pattern matching (proposed new syntax in Python 3.10). It's like a case statement, but the cases support a range of pattern-matching features. This could replace a long-and-messy set of nested if statements with something far easier to comprehend.
Tweet media one
7
24
131
@anthonypjshaw
Anthony Shaw
11 months
My Masters Thesis is now available online. I researched the trend in Python performance and whether it impacts Data Science workloads. I looked at workarounds, changes, improvements in 3.11-3.12 (including sub interpreters) along with lots of benchmarks
4
30
129
@anthonypjshaw
Anthony Shaw
3 years
I see this one a lot. Try..Except statements have an overhead. Don't put them inside a loop unless you have to. Benchmarking both shows putting it outside is 10% faster
Tweet media one
12
11
126