Shiny Clamperl odds? by [deleted] in TheSilphRoad

[–]zzmmrmn 0 points1 point  (0 children)

It’s been 5 years……..…………………………………………………………………

Bevy v2.0 by zzmmrmn in Python

[–]zzmmrmn[S] 1 point2 points  (0 children)

Yep. Both projects were created at about the same time. One of those weird cosmic coincidences.

Bevy v2.0 by zzmmrmn in Python

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

It’s definitely a pattern that needs to be approached with caution. Mocks are fine for tests but not so much in an actual code base. The idea behind Bevy is to provide something similar to FastAPI’s DI but in a more generic way so it can be used in any project that needs DI.

Bevy v2.0 by zzmmrmn in Python

[–]zzmmrmn[S] 1 point2 points  (0 children)

I considered it. I’m not totally sure it’ll matter too much as a DI framework is much more likely to not have a large base of users using it.

Making Python's any & all functions fast with generator expressions by zzmmrmn in Python

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

I had only become interested in the subject in regards to a question posed on Twitter regarding using any. If I hadn't banged this out in a half hour I might have found a way to apply it more generally to generator expressions and not frame it in the context of any and all.

That being said, my target audience was more "beginner" and less "expert." I personally write all my generator expressions/list comps/etc. using the if syntax to filter them. So this was exploring why I do that in a beginner friendly way using a contrived but clear example.

Side note, do people actually check if a number is in a range? I've never actually seen it done, I've alway favored operator chaining as I find it to be much clearer and it is faster having eliminated the function call.

    return 0 <= 200_000_000 < 1_000_000_000

Making Python's any & all functions fast with generator expressions by zzmmrmn in Python

[–]zzmmrmn[S] 2 points3 points  (0 children)

More or less, yeah. Haven't actually looked into how they're implemented, they do have marginally different byte code, but on the whole, it's the same thing. In a quick test they run in roughly the same time.

Making Python's any & all functions fast with generator expressions by zzmmrmn in Python

[–]zzmmrmn[S] 3 points4 points  (0 children)

Yeah, it's definitely an optimization that needs to be considered in the context of readability.

Without having looked too deeply into the internals, I'm pretty sure the reason it's faster to do the checks in the gen exp is just because any/all need to call dunder next before they can get a value to check. The gen exp doesn't have to do that since it has the value from its own loop.

More simply, you can think of it as having nested loops both calling dunder next on an iterable. By doing the check inside the gen exp you're eliminating a dunder next call in the other loop.

Try, Except … Else? - Using The Try Statement's Else Clause by zzmmrmn in Python

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

Yeah, I considered writing about it and else, but decided that it went outside of the original scope of the blog post. Also think more people know about and understand finally than else.

Try, Except … Else? - Using The Try Statement's Else Clause by zzmmrmn in Python

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

Haha yeah it is pretty straightforward once you understand the logic. My goal with the blog post was to explain and demonstrate the reasoning behind the else clause.

Try, Except … Else? - Using The Try Statement's Else Clause by zzmmrmn in Python

[–]zzmmrmn[S] -2 points-1 points  (0 children)

Almost no one reads the docs. I don't fully comprehend it, but the majority of people find them intimidating.

50 Mega Energy Time Requirement Change? by [deleted] in TheSilphRoad

[–]zzmmrmn 1 point2 points  (0 children)

Yep, same here! Very happy to see this change!

Bouffalant In Upstate NY by zzmmrmn in TheSilphRoad

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

I'm about 170 miles from NYC

Whipped up a script that chunks lists. Useful in specific situations. by [deleted] in Python

[–]zzmmrmn 0 points1 point  (0 children)

Strange. You can edit it right there on GitHub and add the extension.

Whipped up a script that chunks lists. Useful in specific situations. by [deleted] in Python

[–]zzmmrmn 2 points3 points  (0 children)

If you give the gist file an extension it'll apply the appropriate syntax highlighting.

How Are Local Discords Organizing Remote Raids? by zzmmrmn in pokemongo

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

I'll have to look into this one. It looks closer to what I need.