Is it common to have someone who is considered "senior" constantly question your code, with questions that are just silly?
ie I have : merged_dict = dict1 | dict2 and senior is halting my PR with "are you sure dict1 isn't being overwritten now? "oh and btw, why did you pass None as default parameter for dict1, instead of setting it directly to {} in the function header.
I feel terrible telling him "that's just how python works, why do you ask these things you're supposed to know them as the more senior position".
Just have to think of a way to not sound condescending or passive aggressive. I might just suck it up and rewrite it to not use mergers even though it will make the code look ugly
@paul23 I recommend a succinct and neutral response, possibly referencing the docs. Something like 'Yes, according to the specification this will "Create a new dictionary with the merged keys and values [...]" without modifying either operand.'
are they supposed to be a senior python dev? because if not, those are completely valid questions. either way, 99 out of a 100 times it's a good idea to be patient and cordial. in my experience, once basic hard skills are met, soft skills are the more deciding factor for advancing your career.
I've got an algorithm and am trying to figure out just what exactly it is canonically called. Personally I would describe it as "window sort" but Google disagrees. It slides over a stream in a window and always emits the lowest value so that almost-sorted streams get sorted.
Somebody knows how these CI things work? github.com/ros2/rcutils/pull/441#issuecomment-1966814917 I tried to comment CI to start a run but it didn't work. Is there a bot which starts it for users with specific rights or is there another way to start it and this just links to the results?
Tapermonkey is such a valuable tool. We have a tool at work which has a large woman as the background to the login screen and she looks very creepy, with it I can just block her :)
I have to say, sometimes it's annoying that python is a slow language. I just had to google how to check if all numbers in a pandas series are integers. In a fast language, pandas wouldn't have had to reinvent all the wheels
oof, the numpy method would be much faster, especially since a Series maps directly to the underlying numpy array
There are other numpy methods discussed in this thread but it looks like there are already methods that don't rely on mod and they seem to really just be talking about friendlier naming for their purpose in this case
I think you could probably collapse that into a single masking pass for both conditions
Hmm, maybe not
"and the two, then check for Trues" assuming you mean "add" then wouldn't you just multiply them into a condition that's either 1 if both True or 0 otherwise?
So you could get it down to three
You could do a single pass if you wanted to fail fast too - just do a mask of arr = arr[arr >= 1] and check the length against the original. Bail if it's different
I bet pythran or numba could compile out the second pass. I won't be satisfied until you've thrown the kitchen sink at getting that extra loop out
(actually, on a slightly more serious note, you could just write the single pass yourself in a function using regular python, throw a @njit decorator on it and it'll outperform numpy)
I don't think I'll ever stop being impressed at just how heavy duty numba is for ridiculously lightweight syntax. 27 mins -> 2.7 seconds with 1 import and a decorator (and, ok, a slight refactoring in the bottom half of the answer to cache intermediate calculations).
The good thing about numba is that it only has one-time overhead. But I'd still have to facepalm at the fact that it parses and transpiles code at runtime
I'm honestly a bit surprised that python programs don't take longer to start up. There's got to be like a bajillion file system accesses due to imports, followed by dynamic code generation if you use numba or dataclasses or something of the sort
I thought it worked more like kernprof just lurking in the background watching what goes on. Though, if you choose not to cache the compiled code, I guess it somehow has to link its compiled code into the runtime
Once it's cached, CPython would just link it I guess on the next run
Yeah, you only have to JIT once if you really wanted, otherwise you just dump it to file for subsequent runs. I'm surprised I don't see it more often when you see questions/answers about it on SO. I mean, why wouldn't you do that unless you're running on a tamagotchi?
@smci Ex Machina died this morning. Pro Machina was born weighing a whopping £167 and 49 pence. I spent days trying to come up with a new name but ran out of time - I need to get all the brand stuff sorted. Still, I think it's more positive on every count (no pleasure-bots), "ex" (a negative word) goes to "pro" and, crucially, all the domain names were available (except for www.pro-machine.com that someone is squatting, but I'm not bartering to cover for a typo!)
I wish mathematicians had a builtin static type checker for their formulas. "Next, calculate the expected value of the mean." Excuse me, what? Calculate the expected value... of a value? How did this gibberish make it into a wikipedia article?
But you could try predict an expected value of a mean. Back to the horrible school examples of drawing marbles from a bag. You have a handful of marbles, each colour assigned a value, and you know the total number of marbles overall. You therefore know the existing mean, and the probability of drawing each of the different colours, so you could estimate what impact drawing a new marble would have on the new mean
I don't know what you're reading, but I'm betting 1.5 Quatloos on "Bayesian" being in the article
Your silence only indicates to me that you're furiously editing it out to win