tushar.pyc Profile Banner
tushar.pyc Profile
tushar.pyc

@tusharisanerd

2,188
Followers
670
Following
611
Media
5,029
Statuses

Metaprogramming • Python / Zig • @zigindia

Bengaluru
Joined December 2018
Don't wanna be here? Send us removal request.
Pinned Tweet
@tusharisanerd
tushar.pyc
1 year
My experience at @EuroPython was easily the best that I've had at a conference, both as a speaker, and as a participant. I got to: - Meet some of the coolest people in the community, - Speak to the biggest audience I've ever seen. Photo credits: @brauliolaraph
Tweet media one
Tweet media two
8
2
41
@tusharisanerd
tushar.pyc
4 months
absolute gem from sqlite source, shared by @iavins
Tweet media one
16
858
8K
@tusharisanerd
tushar.pyc
3 months
I don't know where I found this paper, but this is a great intro to concurrency.
Tweet media one
23
176
3K
@tusharisanerd
tushar.pyc
3 years
🐍Python news: CPython's main branch now compiles to webassembly! Thanks to @ethanhs and @ChristianHeimes Meaning: You can natively download and run Python in the browser. It's about a 5MB package right now. There's plans to make it smaller. Try it here:
27
302
1K
@tusharisanerd
tushar.pyc
2 years
🐍Python TIL: set.discard()✨ Instead of doing⬇️ if item in my_set: my_set.remove(item) You can do⬇️ my_set.discard(item)
Tweet media one
7
30
298
@tusharisanerd
tushar.pyc
3 years
🐍Python Tip of the day: You can use `~i` to index a list in python from behind, instead of `-1 - i`:
Tweet media one
12
33
263
@tusharisanerd
tushar.pyc
3 years
Alright, it's out! And it's by far my most detailed post✨ Understanding all of Python, through its builtins
9
48
235
@tusharisanerd
tushar.pyc
2 years
Tweet media one
19
27
228
@tusharisanerd
tushar.pyc
3 years
@nedbat @realpython My current solution is to add this to my bash profile: export PIP_REQUIRE_VIRTUALENV=true This way, pip will reject all commands outside of a venv. and if a venv is activated, pip will always install it in the right place. No more pip install blunders.
6
44
218
@tusharisanerd
tushar.pyc
3 months
found the link
1
20
189
@tusharisanerd
tushar.pyc
5 months
python is so test oriented, it even has pass and fail commands for your tests:
Tweet media one
Tweet media two
8
14
179
@tusharisanerd
tushar.pyc
2 years
It's finally finished. Here's the long awaited cursed for-loop blog:
9
27
176
@tusharisanerd
tushar.pyc
3 years
Python 3.6, an absolute fan favorite, will have its end of life on December 23. Press F to pay respects On the other hand, this is great news for Python typing enthusiasts, because with Python 3.7 and up: `from __future__ import annotations` becomes available in all versions 🎉
10
17
167
@tusharisanerd
tushar.pyc
1 month
took 2.5 months and a lot of discussion, but managed to land a tiny feature into cpython 🥳
Tweet media one
22
1
152
@tusharisanerd
tushar.pyc
2 months
I love articles like these, that feel like they're talking to me while explaining the concepts in depth.
0
21
148
@tusharisanerd
tushar.pyc
2 years
🐍For all Python Devs: This 1 trick can save you a lot of time and pain. Add this to your `.bashrc` file: export PIP_REQUIRE_VIRTUALENV=true ✨With this, `pip` won't let you install anything into your global environment, which can accidentally break stuff in your system.
Tweet media one
5
32
142
@tusharisanerd
tushar.pyc
3 years
I just had a horrible idea...
Tweet media one
16
20
135
@tusharisanerd
tushar.pyc
3 years
Almost everyday, PIP_REQUIRE_VIRTUALENV saves me from messing up my OS python install.
Tweet media one
8
13
134
@tusharisanerd
tushar.pyc
2 years
I've finally done it. I added *real* for loops to Python. Blog (and package!) very soon.
Tweet media one
30
5
122
@tusharisanerd
tushar.pyc
4 months
"Why do PIDs start at 1, when UIDs start at 0?" Really nice blogpost
1
21
121
@tusharisanerd
tushar.pyc
3 years
I can't believe it's done, but it's really done. Latest blog is out, this time about one of my favorite topics: static analysis 👀 Learn Python ASTs, by building your own linter✨
4
22
118
@tusharisanerd
tushar.pyc
2 years
🐍Just compiled `tomllib` using mypyc. In just 10 minutes of bugfixing, with zero type optimizations (bunch of Any types everywhere), ✨the library runs 2x faster. Zero behaviour changes. With stricter types, I bet it can be even faster. Mypyc has huge untapped potential.
Tweet media one
2
12
117
@tusharisanerd
tushar.pyc
2 months
Just finished implementing a Pratt parser in Zig
Tweet media one
@tusharisanerd
tushar.pyc
2 months
It's 4am. I'm 306 pages into this really interesting book, at about the half way point. And for the *first* time, the author says this chapter is about to get interesting. Damn. Kept reading until 5am, it definitely was interesting. Guess who understands pratt parsers now.
5
0
67
2
4
106
@tusharisanerd
tushar.pyc
11 months
Python 3.13 might be wild for web server performance.
@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
2
14
105
@tusharisanerd
tushar.pyc
4 months
`yen` 0.5 is finally out. ✨ Now you can replace `pyenv`, `virtualenv` and `pipx` with a single static binary. Works on MacOS, Windows, Linux, you name it. is finally obsolete?
Tweet media one
14
6
100
@tusharisanerd
tushar.pyc
2 years
🐍Python Dunder of the day Day 5: ✨__length_hint__✨ Let's do a little obscure one this time. Did you know that dunders can have multiple words? Anyway, take a look at this code:
Tweet media one
5
15
95
@tusharisanerd
tushar.pyc
3 years
Do you really think you understand Python? Here's a not-so-easy puzzle: Why does the first one crash, but the second one work just fine? #Python
Tweet media one
Tweet media two
7
14
85
@tusharisanerd
tushar.pyc
3 years
People writing Python in VSCode, add this to your VSCode settings file: "[python]": { "editor.codeActionsOnSave": {"source.organizeImports": true} } To auto sort your imports on save. Thanks @anthonypjshaw for that tip in the latest article!
2
16
80
@tusharisanerd
tushar.pyc
11 months
It's barely 1 month into development, but Python 3.13 is already impressive ✨ Error messages in the REPL were always a bit hard to read. Look at this example from Python 3.12:
Tweet media one
2
4
83
@tusharisanerd
tushar.pyc
11 months
My de facto stack of libraries for building Python apps these days is: setuptools, build, mypy, black, pytest, tox All other libraries are optional, these are necessary. What's your stack?
23
5
79
@tusharisanerd
tushar.pyc
4 months
@_spook1608 @iavins in #define ? i see it now. thanks i hate it
2
0
75
@tusharisanerd
tushar.pyc
2 years
🐍Python Tip: Want to share a method across multiple classes, but don't want to deal with inheritance / mixin classes? ✨Just assign a function in the class body:
Tweet media one
7
19
65
@tusharisanerd
tushar.pyc
2 months
It's 4am. I'm 306 pages into this really interesting book, at about the half way point. And for the *first* time, the author says this chapter is about to get interesting. Damn. Kept reading until 5am, it definitely was interesting. Guess who understands pratt parsers now.
5
0
67
@tusharisanerd
tushar.pyc
4 months
Pytest amazes me sometimes. TIL pytest makes it super simple to prepend something the PATH env variable for a test:
Tweet media one
0
10
62
@tusharisanerd
tushar.pyc
4 months
Just found out that pipx has been using my code for the past few months! Really grateful, but also I'm kinda about to reimplement pipx in rust :P
Tweet media one
4
1
61
@tusharisanerd
tushar.pyc
5 months
so I might have accidentally made pyinstaller obsolete..
Tweet media one
Tweet media two
Tweet media three
7
4
61
@tusharisanerd
tushar.pyc
3 years
Yes, we all need a keylooger bundled with Python 🙃 #shitoberfest
Tweet media one
5
4
59
@tusharisanerd
tushar.pyc
2 years
Still can't believe my name now exists in the book that taught me Python. @fluentpython is easily the best Python resource I've ever read
Tweet media one
2
3
58
@tusharisanerd
tushar.pyc
2 years
Python Dunder of the Day Day 9: ✨__all__✨ In the last post, we discussed how anything you import into a module can now be imported from that module as well. This pollutes the "module namespace", so to speak. eg. `from os import sys` works, as `sys` is part of os's namespace:
Tweet media one
2
9
54
@tusharisanerd
tushar.pyc
1 year
👋Bangalore folks, We're hosting a meetup about the removal of the GIL in Python, and what means to you as a developer. Come join:
3
15
55
@tusharisanerd
tushar.pyc
24 days
and it begins
Tweet media one
3
1
54
@tusharisanerd
tushar.pyc
3 years
I guess I won't really understand async await in Python until I write my own event loop from scratch.
7
5
49
@tusharisanerd
tushar.pyc
2 months
Hosting a Zig meetup in Bangalore this month. If you're interested in systems programming, you should really be looking into zig. Come join us:
3
8
51
@tusharisanerd
tushar.pyc
5 months
I love this pattern of the first arg being positional only, and all others being keyword only: def do_this(data, /, *, ...rest of options): ...
Tweet media one
6
2
51
@tusharisanerd
tushar.pyc
2 years
Python Dunder of the Day Day 10: ✨__xor__✨ We're starting off with the occasional operator dunders! This time it's `__xor__`, which is interesting, but also straightforward. 🐍If you don't know what operator dunders are, you're in for a ride:
Tweet media one
1
11
47
@tusharisanerd
tushar.pyc
3 years
🐍 Python Tip of the day: Context managers made using `contextlib.contextmanager` can be used as a function decorator as well✨
Tweet media one
1
2
49
@tusharisanerd
tushar.pyc
5 months
I might have built a portable @qutebrowser executable
Tweet media one
1
2
50
@tusharisanerd
tushar.pyc
2 years
👀Received a copy of a book today
Tweet media one
Tweet media two
5
2
48
@tusharisanerd
tushar.pyc
1 month
Zig's formatter won't remove unused, broken imports, so I made a tool that will.
Tweet media one
1
5
47
@tusharisanerd
tushar.pyc
10 months
Alright, time to start reading this.
Tweet media one
2
0
47
@tusharisanerd
tushar.pyc
10 months
damn
Tweet media one
7
1
43
@tusharisanerd
tushar.pyc
1 year
🐍Python Tip: Having trouble inspecting some nested classes you got? ✨Use `json.dumps()` with the `vars` default to dump any object's internals!
Tweet media one
2
8
40
@tusharisanerd
tushar.pyc
2 years
Python Dunder of the Day Day 8: ✨__module__✨ Let's talk about the functools module first: It has some really useful tools, such as `cache`, which caches results from function calls. 🐍This can easily speed up code that has repeated calls to pure functions:
Tweet media one
4
7
39
@tusharisanerd
tushar.pyc
2 years
Python Dunder of the Day 2: ✨__doc__✨ We all know that documentation is important. Python took it a step further, and made docs a part of the code itself. Consider docstrings in a function for example:
Tweet media one
4
9
41
@tusharisanerd
tushar.pyc
2 years
Planning to do a Python dunder of the day for the entirety of next year. ✨Python has at least 150 dunder attributes (__init__ for example), and all of them are interesting in their own way. See you everyday in 2023 then? #Python
2
0
39
@tusharisanerd
tushar.pyc
1 year
One of the best feelings, hearing that your PR will actually help people. 💚
Tweet media one
4
2
39
@tusharisanerd
tushar.pyc
2 years
pathlib is cool, but it can be expensive in very loop-heavy code, always profile your code before jumping to the new best practice. another gripe I had was there was no good way to walk subdirectories like `os.walk()`, but Python 3.12 is adding `Path.walk()`, which is awesome.
@mathsppblog
Rodrigo 🐍🚀
2 years
The Python 🐍 module `pathlib` is amazing. Learning about it will make you 10x more productive*! 🚀 If you want to work with files, you need to know about it! Let me show 5 of the most useful tools in this module 👇 (*Actual numbers may vary. 🤡)
Tweet media one
16
99
552
3
2
40
@tusharisanerd
tushar.pyc
1 year
Textualize has become one of my favorite Python frameworks. Everyone I know who has tried it loves it, and they're doing some of the most interesting innovation in the development space.
1
5
40
@tusharisanerd
tushar.pyc
24 days
I'll be at PyCon India this weekend. I'll also be at PyCon Japan next weekend. Let's meet if you're around!
2
0
39
@tusharisanerd
tushar.pyc
1 year
Releasing a new really simple testing library: ✨astest: `assert` based testing The `assert` keyword exists, it tests stuff, why can't asserts be tests? Well now they can! Take this Python file:
Tweet media one
8
7
38
@tusharisanerd
tushar.pyc
1 year
✨PyPI orgs are finally a thing! "namespaces are a honking great idea -- let's do more of those!"
0
11
37
@tusharisanerd
tushar.pyc
2 years
Python Dunder of the Day 1: ✨__name__✨ You've probably seen code like this before:
Tweet media one
6
6
36
@tusharisanerd
tushar.pyc
1 year
TIL gcc has hand written recursive descent parsers for most of its languages, instead of parser generators.
4
1
37
@tusharisanerd
tushar.pyc
3 months
@bugzapper8 There are 2 hard problems in systems programming 2. Exactly once delivery 1. Guaranteed order of messages 2. Exactly once delivery
0
4
35
@tusharisanerd
tushar.pyc
1 year
Thank you Python.
Tweet media one
4
1
33
@tusharisanerd
tushar.pyc
2 years
Python Dunder of the Day 4: ✨__iter__✨ Python's for loops are extremely convenient, as they get rid of the common "Index out of bound" errors. That's because Python's for loops aren't index based, they're _iterator based_:
Tweet media one
4
4
34
@tusharisanerd
tushar.pyc
2 years
Python Dunder of the Day 3: ✨__builtins__✨ Did you know that functions like print(), input(), range() and others actually come from a module called `builtins`?
Tweet media one
1
5
32
@tusharisanerd
tushar.pyc
2 months
OK, officially switching to uv for making packages, let's see how that goes.
@charliermarsh
Charlie Marsh
2 months
Today, we're shipping a series of features that move uv beyond a pip alternative, and into an end-to-end solution for managing Python projects, command-line tools, single-file scripts, and even Python itself. A single, unified tool. Like Cargo, for Python. It's very fast.
Tweet media one
115
500
4K
1
0
31
@tusharisanerd
tushar.pyc
2 years
Python Dunder of the Day Day 12: ✨__debug__✨ `__debug__` is yet another thing that's defined in the `builtins` module, just like `print()` or `range()`. Let's look at what it does:
Tweet media one
1
5
28
@tusharisanerd
tushar.pyc
11 months
@barryonthefly @Stoichastich @QuantaMagazine it's the "holes" moving because someone messed up the direction of current. because electrons are negatively charged, the direction of current is the opposite of where the electrons went, i.e. where the "holes" were created
2
1
31
@tusharisanerd
tushar.pyc
5 months
They're coworkers Mark works more on the interpreter than Guido these days Guido is annoyed by the notifications that should be going to Mark instead that's all, nothing is changing
@abhi9u
Abhinav Upadhyay
5 months
Breaking: Guid drops ownership of the core python interpreter code
Tweet media one
6
8
143
0
1
29
@tusharisanerd
tushar.pyc
2 years
🐍Python Dunder of the day Day 18: ✨__fspath__✨ I hope you've heard of `pathlib`, it's fairly convenient:
Tweet media one
2
3
30
@tusharisanerd
tushar.pyc
2 years
The `datetime` module is weird. There's an abundance of code snippets that do `import datetime` and others that do `from datetime import datetime`, and they're incompatible with each other. Did you know that the inner datetime is actually a class? It should've been `DateTime`.
3
0
30
@tusharisanerd
tushar.pyc
3 years
A nice proxy metric for how experienced you are with a language is how much you rely on documentation instead of stackoverflow.
2
1
29
@tusharisanerd
tushar.pyc
2 years
Python Dunder of the Day Day 13: ✨__index__✨ `__index__` is supposed to be used when you want your objects to be "index-able". As in, when you can treat your object as a list index, for example. For example, `int` is "index-able" by default:
1
4
27
@tusharisanerd
tushar.pyc
2 years
Wrote a bunch of code in the REPL and need to write it down again? Just open up `~/.python_history` file, your commands will be present at the end.
1
3
28
@tusharisanerd
tushar.pyc
2 years
🐍Before Python 2.7, C code in CPython's codebase didn't have a preference on tabs or spaces. The single largest commit ever made on CPython's repo was on 9th May 2010, when all tabbed C code was migrated to spaces. 318 of 550 C files contained tabs. The change fixed >200k LOC.
Tweet media one
1
2
28
@tusharisanerd
tushar.pyc
11 months
@jatinkrmalik @peakbengaluru this is peak bengaluru
Tweet media one
4
3
30
@tusharisanerd
tushar.pyc
4 months
Just recreated @code_bullet 's latest video idea: Flappy bird but every sprite is its own window. To play, just `pip install flappybird` ✨
2
4
29
@tusharisanerd
tushar.pyc
6 months
Speaking about the GIL's removal and what it means for your code in the future. ⤵⤵
@__bangpypers__
BangPypers
6 months
April Meetup is on 🚨 We've 2 exciting hands-on sessions on #GIL and #Gemini ✨ Bring your laptops or devices and get ready for an awesome event, to be hosted at Google, and sponsored by @googledevs 🔔 RSVP is a must:
Tweet media one
0
3
10
1
5
29
@tusharisanerd
tushar.pyc
4 months
`yen run` runs on windows now so close to shipping the most convenient python env manager ever
Tweet media one
0
1
29
@tusharisanerd
tushar.pyc
3 months
thanks for the pdf @htmx_org !
Tweet media one
3
0
29
@tusharisanerd
tushar.pyc
11 months
Open Source work of the day:
Tweet media one
3
0
28
@tusharisanerd
tushar.pyc
4 months
PEP 2026 is proposing Python switch to 3.<Year> naming starting from 2026. As in, Python release in October 2026 be called 3.26. WDYT?
Tweet media one
14
1
28
@tusharisanerd
tushar.pyc
3 months
I've started micro-blogging on telegram, whenever I do something interesting I write a little bit about it there.
1
6
28
@tusharisanerd
tushar.pyc
4 months
contributing back to pipx (: pipx's next release may have an interesting little flag 👀
Tweet media one
1
1
28
@tusharisanerd
tushar.pyc
2 years
Python Dunder of the Day 5: ✨__next__✨ We learned about __iter__ yesterday, and how it is used to create custom iterables. But the way we did it was sort of a hack: By using `yield`, we just returned a generator from `__iter__()`. In general, an iterable returns an iterator:
Tweet media one
2
5
25
@tusharisanerd
tushar.pyc
4 months
Look what arrived in the mail today!
Tweet media one
4
0
27
@tusharisanerd
tushar.pyc
3 years
It's been exactly one year since I decided to do something open source every day. I'd like to share some of the achievements I've made since: Days contributed: 355/365 Commits made: 2500+ Open source projects contributed to: 28 Repositories created: 42 Open source PR's made: 50+
Tweet media one
2
1
26
@tusharisanerd
tushar.pyc
2 years
I'm exporting my tweets to my blog site , it's so hard to search through old tweets right now. I'll make the tool to do it open source, so that others can also turn their tweets into a website. 🤷‍♂️I want my tweets to be properly indexed. You should too.
Tweet media one
6
0
27
@tusharisanerd
tushar.pyc
3 years
Documentation is scarce? Who cares! breakpoint() + dir() + help() to the rescue!
6
3
27
@tusharisanerd
tushar.pyc
1 year
I did a small meetup in Bangalore talking about the GIL removal and how it can affect how you use Python. The video is up now, check it out:
1
4
27