by hacknat · 9y ago · 0 comments
Also, preach on duck typing it's a python myth that is absurd. If it quacks like a duck means I had to figure out what it was.
This language is slowly destroying my soul, one painful unit test at a time.
For example, I used a decorator the other day that I called `@logperf` that I can pin to any function, which will `logger.info` the approximate time it takes to run the whole function. It doesn't mutate what the function does, it just adds a side effect.
def make_money():
blockchain_pyramid_scheme()
into: @with_jazz_hands
def make_money():
blockchain_pyramid_scheme()
or equivalently: def make_money(*args, **kwargs):
with_jazz_hands(make_money_impl, *args, **kwargs)
def make_money_impl():
blockchain_pyramid_scheme()
Both ways wrap with_jazz_hands around make_money without altering the call sites of make_money.Please, please learn about what higher order functions are in a more general setting before invoking them.
Litterally.
You can take any code with decorators and replace them with this syntax. If you have arguments you must call the factory first, that's the only exception.
So we're two! I'm trying out Rust for a side project now and so far it's fun. Lots of compile-time checks, non-crippled lambdas, and you can use itertools too!
At the end of the day, Python is just an abstraction. It isn't destroying your soul, or doing anything else to it.
OTOH, your conscious decision to stick it out in a job that makes you work with a language that you find "absurd", and where people do things you "absolutely loathe" but have to put up with, anyway? That's what's destroying your soul, man.
Maybe you meant to say TMP?
TMP, on the other hand, is an entirely separate language within C++ that allows you to create monstrous, arcane code that's incredibly hard to debug or understand. Some of the STL uses TMP. But it sounds like custom TMP is the thing you don't like.
I don't quite understand the author's complaint about this specific case of decorators. An initial read makes me wonder why he doesn't use dynamic routes, which is where the decorator / function-name pattern really starts to shine.
Literally, please do not do this shit. Your function should be modular and able to be useable with or without being decorated.