Conversation
Notices
-
I had a discussion with a colleague whether it's ok to put a Python import deep in a function, in a conditional.
He explained that pkg_resources takes 300 ms to load. It basically examines your whole sys.path on import. Pretty annoying when all you want to use it for is just to resolve a path relative to your egg.
So ok, *that* import you can put deep in your function. Otherwise I prefer them all to be at the top and pretend they're declarative.
Looked around and found this still-open issue from last year. Potentially it takes over a second to import, depending on what's on your sys.path and whether your eggs are zipped, etc:
https://github.com/pypa/setuptools/issues/510
> [re: importing pygments]
> with pkg_resources, 244 ms
> without pkg_resources, 2.65 ms
> So just by importing pkg_resources, the slowdown is ~100x. In wall clock time, I have consistently tested the pkg_resources overhead to be at least 150 - 200 ms. This makes pkg_resoucres (sic!) unusable in command line utilities that require fast start up times.
-
@benis Yeah, dynamic everything and imperative everything is super convenient, but comes with a cost. :-/
-
@vertigo That's what I like too, but I think a module that takes a noticeable fraction of a second to import is a valid exception from the guidelines.
-
@benis Any application of macros cannot fix the fact that a language has not been constrained in ways that make it more powerful.
-
@benis No, I said the opposite. Total freedom allows less reasoning about your statements, and therefore fewer interesting things can be done with them by the compiler and runtime.
"'powerful' isn't even a word for microprocessors" is a boring Turing tarpit argument. Let's write everything in assembly. Or why not in "I will only use the Turing-complete conditional-branch-and-modify" assembly.
-
@benis It has everything to do with those things. The reason Python can't optimize those things is thats they are unconstrained. Side effects everywhere.
-
@benis Giggle at *this*.
http://esoteric.codes/post/168290778358/a-programming-language-with-only-one-command-and
-
http://gerigeri.uw.hu/DawnOS/freedom.html
#DawnOS
-
> You plan to just send it with postal service? Wrong, my contry is not a free economy, the prototypes will be STOLEN at the border by the tollers, and i will never receive it - thats how the things go in corrupt maffia-states. So you have to ask somebody to SMUGLER the prototype through the borders, and then send the package to me with the national post inside the contry. The package may also contains handful of cash in random currencys to motivate me.
-
@benis Preprocessors are just copy-and-paste instructions. They do nothing to help any issues with the structure of a language itself. The declarative statements in e.g. Rust and D are something entirely different from C includes.
I love Python. I work with it every day and generally I don't suffer from the language itself compared to other things. But like everything else it's a trade-off between things and sometimes you feel that you're on the wrong side of the trade-off.
Forced whitespace has never been part of that feeling for me.
-
@benis No time for that. That's why we use Python, which together with the code we've written is 80% of that language.
-
@jeff whatever motivation you need, tell me. For me it was getting finally pissed with everything, I decided to do things for myself, and only myself. It reads selfish, but it got me out of the loop.