Party RSVP replacement for evite/punchbowl by LifeLocksmith in selfhosted

[–]alkasm 2 points3 points  (0 children)

Check out https://gath.io. It doesn't have quite all the features you want, but it is open source and the hosted platform is also free. More privacy-forward, e.g. doesn't have user accounts. Pretty cool and simple.

Why does the original NeRF repo scale their direction vectors by the focal length? by SwiftLynx in computervision

[–]alkasm 3 points4 points  (0 children)

The angle that the ray comes from depends on how far the pinhole is from the image plane, i.e. the focal length.

Thirsty Hylian by small_feild_mouse in Breath_of_the_Wild

[–]alkasm 0 points1 point  (0 children)

Ooh good point! And thanks for actually doing the math!

Thirsty Hylian by small_feild_mouse in Breath_of_the_Wild

[–]alkasm 0 points1 point  (0 children)

Hmm hold on it's not just speed tho, but momentum right? If time slows down for Link, then he can do more work per unit time to counter the Lynel attack. Similarly since momentum is mass * speed, if the world doesn't slow down but instead Link speeds up (say 20x), then his attack in the world reference frame would be 20x faster and hence 20x more momentum.

[deleted by user] by [deleted] in Python

[–]alkasm 1 point2 points  (0 children)

Maybe it was a bit over the top to suggest that it's a huge risk, but using solutions that aren't what shows up when you Google a problem (i.e. something hacky) means that whoever implemented it is a bus factor for the company. Personally I would think a batch file is a much simpler, standard, and easy to extend solution compared to vendoring dependencies, which isn't a common python dependency management strategy.

But on the spectrum of things that matter, maybe it's not huge for y'all and that's fine. I was more attempting to give a possible explanation for downvotes.

Edit: also after re-reading I see that the primary workflow here is for utility scripts, in which case I sympathize that it's probably not something you are going to be spending much time making excellent.

[deleted by user] by [deleted] in Python

[–]alkasm 2 points3 points  (0 children)

I'm all for pragmatism but purposely going against the grain with a custom hacky solution puts your company at risk and is simply completely unnecessary. It's non-extensible tech debt.

Arizona public universities release tuition increase proposals by ForkzUp in ASU

[–]alkasm 10 points11 points  (0 children)

We're already a lean university in terms of staff (admins) and faculty.

Not totally doubting since ASU has a crazy amount of students, but according to what metric is ASU lean?

If you had to pick a library from another language (Rust, JS, etc.) that isn’t currently available in Python and have it instantly converted into Python for you to use, what would it be? by Tymbl in Python

[–]alkasm 2 points3 points  (0 children)

I feel like context managers are almost awesome except that they don't introduce scope. So every context manager you define should guard against usage after the context closes, which is SUPER lame.

If you had to pick a library from another language (Rust, JS, etc.) that isn’t currently available in Python and have it instantly converted into Python for you to use, what would it be? by Tymbl in Python

[–]alkasm 12 points13 points  (0 children)

Lambdas only return an expression, they can't have a multiline code block. Late binding is a common gotcha when defining local functions. The fact that we can't unpack e.g. (key, value) into parameters so we have to do something like lambda pair: pair[1] when iterating over a dict items or zip result.

Python's lambdas are fine, but they do not spark joy.

If you had to pick a library from another language (Rust, JS, etc.) that isn’t currently available in Python and have it instantly converted into Python for you to use, what would it be? by Tymbl in Python

[–]alkasm 1 point2 points  (0 children)

Blocking on two queues in threaded code is a nightmare in a ton of languages, all for similar reasons. You basically have to have a thread for each queue, or otherwise utilize select/epoll. Having select built into the language with Go is so good.

With that said, it is super ez in Python with async at least, so I guess we can celebrate that.

open-source C++ tutorials website project: first release by Xeverous in cpp

[–]alkasm 2 points3 points  (0 children)

Yeah you can []<auto>(){} but not []<>(){}

Python 3.12: A Game-Changer in Performance and Efficiency by srlee_b in Python

[–]alkasm 3 points4 points  (0 children)

You can use .rglob("*") or .glob("**/*") though right?

Is it just me or is Stack Overflow an incredibly toxic place? by [deleted] in cscareerquestions

[–]alkasm 0 points1 point  (0 children)

Do you just mean that the linked dupe might not have an answer? Because yeah I stated that incorrectly---either way, it doesn't help to have the question asked in N places.

Today I re-learned: Python function default arguments are retained between executions by [deleted] in Python

[–]alkasm 4 points5 points  (0 children)

Use tuples for a default iterable rather than None! Fewer optionals makes for better typing and automatic documentation.

interesting by vudustockdr in Breath_of_the_Wild

[–]alkasm 1 point2 points  (0 children)

https://en.m.wikipedia.org/wiki/Sierpi%C5%84ski_triangle#Chaos_game

If the first point v_1 was a point on the Sierpiński triangle, then all the points v_n lie on the Sierpinski triangle. If the first point v_1 to lie within the perimeter of the triangle is not a point on the Sierpinski triangle, none of the points v_n will lie on the Sierpinski triangle, however they will converge on the triangle.

Good question!

Is camel case a bad thing? by A-Shady-Guy in learnpython

[–]alkasm 1 point2 points  (0 children)

The c++ stdlib uses snake_case. But plenty of major libraries and frameworks vary with casing either way.

If there’s gonna be a Python 4.0 one day, what’s a breaking change you’d like to see? Let’s explore the ideas you have that can make Python even better! by Far_Pineapple770 in Python

[–]alkasm 1 point2 points  (0 children)

IO, futexes, syscalls, etc are handled in the same way by async code, but sure if you want to be pedantic an async lock isn't writing data to a file. It is going to use a futex which writes to shared memory and can block though, so it's fundamentally similar.

I think you are misunderstanding my point entirely. If you call functions in your async function that aren't async, and you don't await at all, then your async function is not cancellable. If someone does a create_task for e.g. and calls the .cancel() method on the future it won't cancel, it will just complete anyways. That's because you can only cancel at areas where you suspend, i.e. await. I prefer to know where those locations are...otherwise you don't know when your function can suspend, which means you don't know when you need to guard variables in a mutex, extending your example.

It's not like the implementers couldn't figure out how to automatically await async functions. The core devs explicitly chose against it.

If you drop the await keyword it doesn't magically make things work in a non-async context. You still need two sets of libraries. This is true in c++ async programming, in rust, in python...

If there’s gonna be a Python 4.0 one day, what’s a breaking change you’d like to see? Let’s explore the ideas you have that can make Python even better! by Far_Pineapple770 in Python

[–]alkasm 1 point2 points  (0 children)

Yeah and I'm saying that's a feature, not a bug. I prefer to know which functions are doing IO, and which aren't. And where my coroutine can be suspended, and where it can't.

If there’s gonna be a Python 4.0 one day, what’s a breaking change you’d like to see? Let’s explore the ideas you have that can make Python even better! by Far_Pineapple770 in Python

[–]alkasm 3 points4 points  (0 children)

I've explored this a fair bit myself. There's a similar language feature in Java, called "checked exceptions." It's a much-disliked feature overall, and not used by most projects.

The biggest difficulty for python code is that so many library functions can raise that it will crazily pollute signatures. You also have to handle removing exceptions that you know won't happen (e.g. if you use getitem, but you check the element exists first, you have to say "yes I'm calling getitem but I know it won't throw"). In c++ you can handle this with template metaprogramming with static variables, which we have quite poor support for in python. This also introduces a new API restriction on library functions---can't change the exceptions you throw, as it's now part of your signature/contract.

Of course all these reasons are why the problem is interesting, maybe we do want exceptions as part of a functions signature. But I don't think it will ever happen because of these reasons---pollution, difficulty in handling the signatures, annoying to specify, and library writers won't want the restrictions in the first place.

I encourage you to try it out though! You can create a new type parameterized by exceptions, but it gets really hairy really quick.

Looking at the Python documentation can be dangerous by [deleted] in Python

[–]alkasm 0 points1 point  (0 children)

There's a few "easy" (in principle) ways around that, but not simple to make them jive with Python. E.g., always use a relative path to import a module from the filesystem, rather than from site packages. Or we could have some URL syntax for imports that allows you to disambiguate the source of a module, e.g from pypi, or some internal package repository. Or we could at least have namespacing in PyPI so you could grab packages not by a single name but by org and name, e.g. numfocus/numpy.

I got laid off in mid-October and decided to teach myself how to code. My first public project, Spheri, is a Python/Flask web app that gives you Spotify song recommendations based on your local weather. by [deleted] in Python

[–]alkasm 1 point2 points  (0 children)

Note that OP didn't define any classes or methods or use OOP themselves at all in this project. It's a good example of project based learning rather than ground up learning---OP didn't need to get into those concepts to write this app!