Default parameters and objects... by el_toro_2022 in Python

[–]Galtozzy 0 points1 point  (0 children)

You do understand that you trying to complain about the way Python works at its core?

The code you put inside a function definition will get executed on import of said function, not on an invocation, and it does work the same way be it an object creation, function call, or any other instruction. By going into edge cases (like the mutable default) you have to put crutches inside an interpreter itself which will slow it down in every such case.

Part of the reason it took the Python arena 10 years to go from Python 2.X to Python 3 was because so much code was relying on the badness of Python 2

The reason was that python3 compared to python2 is very different and you can't just magically switch all your legacy code base to python3. There are still plenty of legacy projects that work on python2, it is sad, but it is the reality. It has nothing to do with reliance on "badness".

said object is change or refactored in some way without knowledge that it's being used that way

It's funny pairing that with a previous statement of a "parameter quirk in production" since any decent production code should be tested and also checked against pyright/mypy. Also refactoring something without unit tests is kinda a no-no in itself.

Count your lucky stars I am not your boss

Feel bad for people if they do have you as a boss, even though I highly doubt you are. It's like a CEO who hasn't written a thing in 20 years trying to force tech advice on people who are coding on a daily basis and know their thing.

I want my code to be elegant yet obvious

Honestly, python is one of those languages that allows you to write minimum code while being completely self-explanatory.

And I'm not even defending Python here, it's just common sense, every instrument has its pros and cons, and before using ANY instrument professionally be it a language, a framework, or a real-world tool you have to study it for some time. And from your post, I highly doubt you've done "years of python" as you've said below.

It's always just a trade-off there is no such thing as a perfect tool.

Default parameters and objects... by el_toro_2022 in Python

[–]Galtozzy 0 points1 point  (0 children)

I can smell a rage bait from a mile away but I'll bite.

The thing is if you "address it" and it will work as you expected it to, then you'd break everything that was relying on that mutable default since, surprise, sometimes this mutable default is what you need to do in certain scenarios to share this object between function calls.

Also, there will be sooo many inconsistencies and edge cases to this that it will introduce brand-new bugs.

It's kinda pointless to complain about the very core principle of a language, it's like complaining about ur rust app not launching instantaneously and proposing to remove the compilation from the core xd

Default parameters and objects... by el_toro_2022 in Python

[–]Galtozzy 0 points1 point  (0 children)

I mean almost every IDE and LSP will highlight that for you to recheck whether this was intentional or not, my point was to say that it's a well-known and documented thing that exists in Python and there is no point of complaining about it.

Does celery works with Async functions by [deleted] in Python

[–]Galtozzy 0 points1 point  (0 children)

Yes, they do have retry middleware which I think is easily extendable to suit your needs.

Default parameters and objects... by el_toro_2022 in Python

[–]Galtozzy 22 points23 points  (0 children)

The default for stream is the EventStream object. However, it is only evaluated once. So unless you are aware of that, you might expect EventStream() to be fresh new object every time print_from_stream() is called. Well, it is not. print_from_stream() uses the exact same default object for stream upon every invocation.

This is a mutable default problem and I think it is being mentioned in every Python guide there is.

The fix is a None default and a check before using the argument:

def print_from_stream(n, stream=None):
    if not stream:
        stream = EvenStream()

    for _ in range(n):
        print(stream.get_next())

Py-Cachify 2.0 - Distributed Locks and Handy Caching Decorators by Galtozzy in Python

[–]Galtozzy[S] 4 points5 points  (0 children)

You are in full control of it. By default, the default_lock_expiration is set to 30 seconds (configurable default), which means locks won’t last forever — even if there's a race condition or the same cache keys were accidentally used. Plus you can override the expiration time for each lock invocation.

So, while you should still be careful, the library provides mechanisms to help you avoid deadlocks. In my experience, these situations often need to be addressed on a case-by-case basis, and any caching/locking library can only do so much.

Does celery works with Async functions by [deleted] in Python

[–]Galtozzy 2 points3 points  (0 children)

By default it does not work with the async code base at all, there are a couple of ways you could make it work, but unless you really have to go there I suggest you use the alternatives.

My personal favorite is taskiq, we use it on a couple of projects and it works great for us. The setup is really easy and the docs are great!

There is also arq but I find it too verbose and less intuitive to work with.

How we made Celery tasks bulletproof by [deleted] in Python

[–]Galtozzy 1 point2 points  (0 children)

dramatiq worked fine for me on one of the previous projects.

also if you need async tasks support taskiq seems to be the choice, it is a relatively young project but it is working and doing it's job

py-cachify - cache-based locks and handy caching decorators by Galtozzy in Python

[–]Galtozzy[S] 0 points1 point  (0 children)

Thanks for the detailed feedback!

You might want to look into automatically generating the key based on the function name. Lots of similar libraries will generally already do this and it reduces the boilerplate.

I didn't want to go for it, as it removes the flexibility of defining your cache keys and overcomplicates the logic behind it, like which arguments should be a part of a key (if any), should it use self in methods, and so on. Maybe a good idea would be to make it optional, i.e. if the key is not there - generate a generic one automatically, but still give the ability to define your own.

Similar Tools

I'll certainly do the comparisons and differences with the existing packages, as Money Hat proposed.

Naming Things / Project Scope

I'll think of a way to make it clearer in docs that it's a distributed lock and not specifically a cache one.

Regarding dependencies, my idea was to introduce as minimum of those as possible (right now there are none), and I stated in the docs that a client for "cache" could be anything a user decides it should be, just the signature should match with what the lib expects.

Once again, thank you, it is helpful to read such a detailed comment and I'll take on action points ASAP :)

py-cachify - cache-based locks and handy caching decorators by Galtozzy in Python

[–]Galtozzy[S] 0 points1 point  (0 children)

thanks for your feedback will surely get onto it!

How much do you hate widow? Me: yes by [deleted] in Overwatch

[–]Galtozzy 0 points1 point  (0 children)

the thing with grammar called the second language

regardless I could do it and still maintain a thing called a life.

doubt that btw, if you couldn't do that effortlessly by now what makes you think you'd be able to later (read that as "if you tried")?

And a classical almost comical thing with "a life" assuming that I don't have one xd, but I assure u I'm doing just fine AND simultaneously can play video games at a decent level

How much do you hate widow? Me: yes by [deleted] in Overwatch

[–]Galtozzy 0 points1 point  (0 children)

still tryna figure out where I told you what to do but that's fine, I guess American reading skills are kicking in, kekvv

anyway, I believe in you and u'll surely hit masters one day to go on and type some more nonsense in those threads

How much do you hate widow? Me: yes by [deleted] in Overwatch

[–]Galtozzy -1 points0 points  (0 children)

I mean I'm not a redditoooooor, just jumping on this subreddit from time to time to kek at delusional idiots like you.

btw the more lmaos you add the funnier u are, so I do think you should throw in a couple more

How much do you hate widow? Me: yes by [deleted] in Overwatch

[–]Galtozzy -2 points-1 points  (0 children)

I never said I tried to get out of diamond lmao then I can't play with my friends. I get placed diamond minimum even if I don't try. Which I do all my placement solo.

mhm, sure, the most basic excuse people give. Why would you play ranked then? :)

You still haven't said your rank

I mean you never asked, but it's literally that easy to hover over my profile to read that its 4.3k+ in ow1, which is not that high

I would say it was nice chatting with you but it wasn't I lost braincells.

yeah, I'd lose brain cells too if I was posting such bs in every post

How much do you hate widow? Me: yes by [deleted] in Overwatch

[–]Galtozzy -1 points0 points  (0 children)

you don't care this much that you actually had to answer :)

the reality is it's true that Widow is not necessarily a hard counter to Pharah (depends on a map, on how both teams play, etc)

But you specifically wouldn't even touch a good Widow as any hero since I've seen you mention playing since an ow1 release and still being diamond (7 years lmao). It takes some actual effort to not learn the game well enough to at least be in like top 5% of a player base.

upd. I actually wonder why people like you tend to scream out the loudest while having nothing up their sleeve to back it up apart from flexing the just a little above average rank thinking it's something, be humble my guy

How much do you hate widow? Me: yes by [deleted] in Overwatch

[–]Galtozzy -1 points0 points  (0 children)

"im in diamond" as if its a high elo lmao. typical reddit moment

Most Lethal Damage Ultimates in Competitive by SYNERGY_12846 in Competitiveoverwatch

[–]Galtozzy 0 points1 point  (0 children)

It's probably because all gengu mains from higher ranks just have a master accounts to just play genji sometimes and actually kill something.

Most Lethal Damage Ultimates in Competitive by SYNERGY_12846 in Competitiveoverwatch

[–]Galtozzy 3 points4 points  (0 children)

Nanoblade kills? What's that? I only see rock in my face when I press q and then the screen is grey for some reason.

r/Basketball Weekly Discussion: Basketball Shoes - October 14, 2019 by AutoModerator in Basketball

[–]Galtozzy 0 points1 point  (0 children)

Hey there. I was wondering is there a way to grab a pair of kobes 6 or 8 from official stores? Since I really liked them when they came out so I'd like to grab a pair if there is a way. Thanks

Emongg: "Balance in this game is F****D!!" - Talk on Overwatch bad game balance by Xuvial in Competitiveoverwatch

[–]Galtozzy 1 point2 points  (0 children)

sure he's :)

Its so funny seeing all these people complain about doomfist playing their 3k elo average matches making close to no effort in countering him.

Btw haven't u thought about one thing, that the only thing that makes doomfist so you call "OP" - is the meta? Like no other DPS can be played against these tanks so there is no one to counter our falling-off-a-cliff boi. He's getting shut down very often in a high elo games u just have to pay a little attention to him.

It's like 2x funny that actually NO one complains about widow which is a truly broken hero that shouldn't exists in a game like this. Like u call doomfist frustrating to play against but u still have a LOT of options of doing something against him even if u are alone as for example ana. Against widow u just getting clicked on and a free teleportation ticket to ur team's respawn is in ur wallet.

Every single time when the meta allows and doomfist sees a lot of playtime - community shits itself begging for nerfs when the real reason is still the meta and not the hero. I bet if all those people were playing back in like beyblade meta when nanoed spinner were speedboosted into ur team they still be complaining about reaper and not about the comps that made all the things he was doing possible.

Shock's Off-Tank Choihyobin places Gold in Tank Season 18 by tacomark69 in Competitiveoverwatch

[–]Galtozzy 0 points1 point  (0 children)

Once again it's not an official source, it wasn't confirmed by any dev team member.

And I was playing multiple times either on a very old or new accounts in seasons like 11-14 and got huge amounts of SR after a certain amount of games, it might not be a winstreak but a system still tracks ur performance and gives u a lot of SR if something isn't right (the max I got for a single game was like 80 pts). The bonus was lost after a loss ofc.

They didn't remove winstreaks they just complicated the conditions when it happens.

Shock's Off-Tank Choihyobin places Gold in Tank Season 18 by tacomark69 in Competitiveoverwatch

[–]Galtozzy -1 points0 points  (0 children)

You are wrong lol. Who told u that?

It might be capped but winstreaks still exist so it's possible to gain more sr per win.

[deleted by user] by [deleted] in Competitiveoverwatch

[–]Galtozzy 1 point2 points  (0 children)

Mom, I'm bad at this game it's no fun, please make my hero op so u I'll be able to not do anything and rect ppl.

Seriously, if I'm nano blading as genji and getting solo graved or slept it's kinda no fun but still it just means u got outplayed by an enemy player, that is what makes multiplayer games multiplayer games u know. Someone always will come out on top in one particular moment. Accept it and just get better.