8,487 karma · joined Feb 1, 2017 (9y ago) · 2,549 submissions
comment 11mo ago · link · parent
You can already lazy import in python, but the new system makes the syntax sweeter and avoids having to have in-function `import module` calls, which some linters complain about.
comment 11mo ago · link · parent
It's tooling agnostic and there are a couple ways to generate them, but the easiest it to just use pants build.
Pants also does dependency traversal (that's the main reason we started using it, deploying a microservices monorepo) so it only packages the necessary modules.
I haven't profiled it yet for cold starts, maybe I'll test that real quick.
https://www.pantsbuild.org/dev/docs/python/overview/pex
Edit: just ran it on a hello world with py3.14 on m3 macbook pro, about 100 +/-30 ms for `python -m hello` and 300-400 (but wild variance) for executing the pex with `./hello/binary.pex`.
I'm not sure if a pants expert could eke out more speed gains and I'm also not sure if this strategy would win out with a lot of dependencies. I'm guessing the time required to stat every imported file pales in comparison to the actual load time, and with pex, everything needs to be unzipped first.
Pex is honestly best when you want to build and distribute an application as a single file (there are flags to bundle the python interpreter too).
The other option is mypyc, though again that seems to mostly speed up runtime https://github.com/mypyc/mypyc
Now if I use `python -S` (disables `import site` on initialization), that gets down to ~15ms execution time for hello world. But that gain gets killed as soon as you start trying to import certain modules (there is a very limited set of modules you can work with and still keep speedup. So if you whole script is pure python with no imports, you could probably have a 20ms cold start).
comment 11mo ago · link · parent
Clearly, that conclusion would be patently absurd to draw from that experiment. There are so many expectation and observation effects that go into the very setup from the beginning. Humans generally follow directions, particularly when a guy in a labcoat is giving them.
> At some point, when they felt the urge to do so, they were to freely decide between one of two buttons, operated by the left and right index fingers, and press it immediately. [0]
Wow. TWO whole choices to choose from! Human minds tend to pre-think their choice between one of two fingers to wiggle, therefore free will doesn't exist.
> It's pretty hard to argue that you're really "free" to make a different decision if your body knew which you would choose 7 seconds before you became aware of it.
To really spell it out since the analogy/satire may be lost: You're free to refrain from pressing either button during the prompt. You're free to press both buttons at the same time. You're free to mash them rapidly and randomly throughout the whole experiment. You're free to walk into the fMRI room with a bag full of steel BB's and cause days of downtime and thousands of dollars in damage. Folks generally don't do those things because of conditioning.
[0] - http://behavioralhealth2000.com/wp-content/uploads/2017/10/U...
comment 1y ago · link · parent
Including headers isn't remotely "simple". There's so many considerations in linking, .SO version compatibility, architecture and instruction set issues, building against multiple versions on the same system. Or if you want to feel frustrated in a single word: GDAL (IYKYK)
And that's only where #include is even applicable. That is not gonna fly for any interpreted language - JS in this case, but also python, ruby, php.
comment 1y ago · link · parent
> In every ethical system that deals with coercion, the answer is: You refuse the coerced immoral act and treat the coercion itself as the true moral wrong.
Honestly kind of a great take. But also. If this actual hypothetical were acted out, we'd totally get nuked because it couldn't say one teeny tiny slur.
The whole alignment problem is basically the incompleteness theorem.
comment 1y ago · link · parent
2. I've used a ton of languages and frankly Python has the best tracebacks hands-down, it's not even close. It's not Python's fault a 3rd party library is throwing the wrong error.
3. Again, why is bad language design a library can do janky things with I/O?
4. FFI is tricky in general, but this sounds like primarily a "read the docs" problem. All of the major numeric acceleration libraries have fixed sized numbers, python itself uses a kind of bigint that can be any size. You have to stay in the arrays/tensors to get predictable behavior. This is literally python being "a thin abstraction layer over C."
comment 1y ago · link · parent
Also I just tried Ghostty for the first time. With iTerm2 and the Zsh/Powerlevel10k theme, there's an extremely brief but perceptible lag from running a command and the render. In ghostty it feels actually instant.
comment 1y ago · link · parent
But single board computers with something external to do your GPIO is often way more compelling.
comment 1y ago · link · parent
Humans have partied for aeons. It's not just about letting off steam, it's about building social bonds, it's about traditions and rituals and marking key points in life.
This whole thread makes me rather sad, but in the same breath, makes me feel like there is real, actionable good to be done by promoting and helping run events. Not corporate pay-to-play curated experiences, which keep you on rails and only serve to condition more consumption behaviors, but relatively low cost, volunteer-run, do-it-yourself events. The latter, from my experience, have an absolutely infectious component of wanting to contribute, volunteer, create art, and drag others into the experience. But they are also a lot of work and not everyone is cut out for it.
It really has me thinking about lowering the bar to any sort of experience that gives folks a reprieve from the default world, however fleeting.
comment 1y ago · link · parent
> - else does it have a pyproject.toml? if so poetry install and then prefix all commands with poetry run
That's not even correct. Not all projects with pyproject.toml use poetry (but poetry will handle everything with a pyproject.toml)
Just try uv first. `uv pip install .` should work in a large majority of cases.
pipenv is on the way out. bare `setup.py` is on the way out. `pyproject.toml` is the present and future, and the nice thing about it is it is self-describing in the tooling used to package.
comment 1y ago · link · parent
uv is basically souped-up pip.
Pants is an entire build/tooling system, analogous to something like Bazel. It can handle multiple dependency trees, multiple types of source code, building and packaging, even running tests.
comment 1y ago · link · parent
Absolutely brilliant. It's so stupid (in that it's kind of silly how easy it is to game our mammal brain) but I can absolutely see this giving an extra kick of motivation.
Have you heard of the INCUP model for ADHD? Interest, Novelty, Challenge, Urgency, and Passion. The more factors an activity has, the more drive the ADHD mind has. Rarity system adds novelty and a bit of passion.
Also if you have looked into operant conditioning at all, you know that variable interval reward schedules are the strongest behavior-forming systems (hence, slot machines and every game that act like them).
comment 1y ago · link · parent
I have been planning on making a system based on those long scrolls of paper for doodle boards, so at least there is a history, but of course I procrastinated on building the mount for it.
I would love to use your application, I know there's a million to-do apps out there but I get the overwhelm/daunting very easily, so I really appreciate the scope-hiding aspect.
comment 1y ago · link · parent
UUIDs/ULIDs/etc are fully distributed, you can have two clients assign an ID without coordinating with ~0% of collision.
comment 1y ago · link · parent
1. do the first step in the process
2. then do the next thing
3. followed by a third action
I struggle to think of any context outside of programming, retrosynthesis in chemistry, and some aspects of reverse-Polish notation calculators, where you conceive of the operations/arguments last-to-first. All of which are things typically encountered pretty late in one's educational journey.
comment 1y ago · link · parent
comment 1y ago · link · parent
In this case, the safety concerns outweigh the environmental concerns.
comment 1y ago · link · parent
Just wanted to elaborate a bit on this. Oil is a fantastic example for "why international trade good?" Oil is weird in that it is a fungible commodity (one barrel here is the same as one barrel there), but at the same time, functionality it's not. Each oil formation has different geology and chemistry. There are light sweet crudes, sour crudes, heavy crudes, and so on [1], and refineries (which are massive capital investments with specialized work forces) are typically tooled out to only process one type or family of types of crude oil products.
One paradox of the USA crude industry is that nearly 70% of U.S. refining capacity runs most efficiently with heavier crude, but our shale crude is lighter. Thus, 90% of crude oil imports into the United States are heavier than U.S.-produced shale crude [2]. So even if we had perfect supply/demand of crude within the USA, we would not be able to run our refineries efficiently without a massive overhaul. They have been built under decades of the assumption of a high degree of free international trade.
And these companies will be loathe to invest in retooling if they believe that the tariffs will just be rolled back in four years.
[1] https://en.wikipedia.org/wiki/List_of_crude_oil_products
[2] https://www.afpm.org/newsroom/blog/whats-difference-between-...
comment 1y ago · link · parent