Today I re-learned: Python function default arguments are retained between executions
What is the best practice for __init__ with many arguments?
Making defaultdict create defaults that are a function of the key.
You should put this on the Python Cookbook.
More on reddit.comWhy does python's async execution model so strictly separate synchronous from asynchronous functions?
I just ported a large project (50K LOC) completely to async. I changed thousands of lines of code.
First, I love the async model and everything about it.
However, I really shouldn't have had to do all that work. It isn't just adding a bunch of async and await everywhere. It is converting every for loop into an async for loop. It is converting every context manager and list comprehension into an async one. It is converting yield from back into regular loops. It is rearchitecting things if you have a generator expression. Essentially there are two syntaxes now, one for async functions and one for non-async, and they haven't transitioned all the syntax from non-async to async yet.
Essentially, when you mark a function as async, you're telling the interpreter that someone, maybe 7 layers deep, might wait on a OS object. You could have 99% of your code be non-async, but because of that one dude (probably waiting on a socket), thousands of lines of code have to change. This viral nature of async is bad. I don't mind marking the functions, I do mind converting code from one syntax to another simply because it makes the interpreter slightly easier to implement.
If an async function calls another async function, the await should be implicit. There should be some other keyword to *NOT* await on a called coroutine. In this way, you wouldn't have to rewrite every function.
More on reddit.com