« first day (2641 days earlier)      last day (2310 days later) » 

9:01 PM
We just (re)discovered an interesting Python behavior: if you import a module with a syntax error, the error is raised but an empty module is still registerd in sys.modules.
 
and I just found an interesting behaviour in one of my recent scripts wherein I accidentally used the raw input rather than a postprocessed dataset
 
wim
@davidism can't reproduce
are you sure it doesn't only happen with packages?
 
What happens if an imported module monkeypatches some code and then syntax errors?
 
wim
hmm, can't reproduce with package either (python 3.6)
 
Actually, presumably syntax error is a stupid example. What if it 1/0s
 
9:09 PM
I'm having an issue with trying to build a python extension using Miniconda3 on a Mac. Is this the right place to ask for help debugging this?
 
@wim I didn't actually try to reproduce it before, but I can't do it with a simple example either. Maybe it's specific to the reloader thread? Going to try that next.
 
I'm posted a lengthy question about this on stackoverflow but did not get a response yet.
 
@kdheepak welcome, please read our rules: sopython.com/chatroom
 
I was wondering i someone would be willing to talk through this to help me see if I'm missed something.
Great! Thanks for the chatroom rules.
I'll wait longer for someone to answer my question on stackoverflow. If noone is able to provide an answer, I'll come back and post over here.
 
user5500750
raspberry pi works on Python?
 
9:22 PM
More the other way round, I believe
 
user5500750
Does it support C++?
 
Hmm, I wonder how functools.lru_cache interacts with default arguments...
 
it doesn't cache mutable stuff, does it?
 
you mean unhashable stuff?
 
oh, but your point is not passing anything at all
it can not know about a mutable default arg if you don't pass it; is that what you have in mind?
@Rawing probably
 
9:29 PM
I'm not thinking of mutable arguments, no. Just wondering if explicitly passing the default value for an argument would result in a cache miss after you've already called the function without passing a value for that same parameter
 
@Rawing It treats them like any other arg, IIRC. I can't test because I'm on my phone.
 
it is indeed a cache miss:
@functools.lru_cache()
def func(arg=1):
    return arg

func()
func(1)

print(func.cache_info()) # CacheInfo(hits=0, misses=2, maxsize=128, currsize=2)
 
oh I see
I would expect that the decorator only sees what you explicitly pass
and that seems to be consistent with my expectation
 
I don't like that. It should use all the args. But, yeah, there's no way for the decorator to see the default args.
 
9:33 PM
I'm not sure what else could it do as a decorator
my impression is that it's like one of those ATM hacking gadgets that go on top of the interface and steal your PIN and card data man-in-the-middle style
 
DSM
Sorry, why can't the decorator see the default args?
 
it's easy with some inspect.signature magic
 
DSM
By the time the decorator gets passed the function, the default info is already bound up there.
 
@DSM my naive impression is that what we see is lru_cache(function)(*args,**kwargs), but if we never pass those kwargs because they're default, it can't cache it.
 
I wonder if there's any edge cases involving not-so-easy defaults that maybe don't implement __eq__
 
9:36 PM
is that false in itself, without introspection thingamajigs?
 
Well, I guess it can snoop them from the original function it wraps it just can't see them in the call
 
And/or the additional level of testing
 
DSM
I think we could have written the decorator to cache on the effective args, not the passed args.
 
But that's "hard", right?
compared to "construct a dict of input parameters used so far, with the corresponding return values"
 
What? Is it true that low rep users can't delete their own answer?
I'm taking < 10 rep
 
9:38 PM
Haven't heard that one. But accepted answers can't be deleted. Context?
perhaps they aren't registered users
 
DSM
I don't know, I did something similar to create some regression test tools last year, using some of the Signature stuff Rawing mentioned. Wasn't too bad.
 
Ah, I missed his remark. So yeah, I think we're saying the same thing.
 
But clearly it doesn't do that, as Rawing's test shows. Also Andras' test with the empty list would have raised an error, since it complains if you try to give it an unhashable arg.
 
9:39 PM
I mean, the validity of my claim doesn't include all the tricks up your sleeve :)
 
@DSM Sounds good to me.
 
Wow... them answers tho
 
Should I report these two ppl.? stackoverflow.com/questions/48154990/…, read the comments.
They were being really rude.
 
9:45 PM
Blunt, yes. Rude, I'm not so sure.
 
I don't want @theworstcoder to leave SO just because of these two rude ppl.
 
What makes you think these are rude people ?
 
he simply wanted to know how to open read and write files, they were just making fun of his lack of knowledge
 
Like Kevin said, these people, to me at least, seem very direct and blunt, doesn't seem to be rude. I don't think they are directing anything personal towards OP, maybe the "wrong business comment might be border line but eh...
 
Nope, not borderline
 
9:47 PM
@cᴏʟᴅsᴘᴇᴇᴅ to which side of the line
 
It's simple, Zeus, you can report it if you think they are being rude. If you are asking for opinions, I don't think they are being rude.
 
I can empathise with their comments, though I might've worded things a little differently. It's hard to remain fair and gentle when you've been dealing with the same dredge for months
 
But, hey don't they want free rep.?
 
And let's be honest, no matter how pure OP's intentions were, they still asked a crappy question which deserved to be downvoted and closed for lack of research or effort into writing it
 
And I can almost guarantee majority of coders will not leave Stack Overflow. They might not participate as often, but Stack Overflow is such a rich resource for coders, it's hard to "leave".
 
9:49 PM
True but they attest point him in the right direction
 
@Mr.Zeus Reputation is more than the number on your profile. You might earn rep faster by answering those questions, but you lose the respect of the community.
 
@Mr.Zeus This site isn't all about reps. :\
 
what do you expect from people talking to "the worst coder"?
 
I know, it was a joke
 
We all have a keen interest in keeping the site clean, and that entails taking out the garbage every now and then
 
9:50 PM
And they did point the OP towards the right direction. Told them to research and try things first...
 
I don't think they're "idiots", if anything you'd need to Be (a bit more) Nice.
 
@cᴏʟᴅsᴘᴇᴇᴅ devil's advocate: you can take out the garbage and not be a butt
 
Well, yes. But I don't think they were being rude or disrespectful. Curt? Yes. Blunt? Yes.
 
@AndrasDeak woah woah woah. can you do it for a year straight? maybe? maybe not? but once you're burn out then what? thanks for helping now step aside? seems kinda harsh :( it's lose lose no matter what man :( life is hard
 
I changed what I said, I regret what I said
Sorry I did not mean to cause such an uproar, :P
 
9:53 PM
hardly an uproar o.o not to dismiss your comments or anything. I just don't want you to think this is an uproar and discourage you from asking questions about the meta of this site in the future
 
wim
@DSM for example, it is possible to dynamically alter the default args at runtime
so probably safest not to use the ones that happened to be defined at decoration time
 
I should stop typing my first half of my thought and hitting enter. should really complete my thought in a complete manner before hitting enter :\ I blame MSN for this bad habit.
 
I blame Trump
 
Also @MooingRawr, the maybe not just stop at SO and think that coders are just unkind nerds, not at all welcoming.
When in reality most of us are very inviting.
;)
 
did you mean to type "they maybe not"? If so then that's their fault and they are prejudging based off a bad experience, then so be it, couldn't care less lol.
 
9:57 PM
"complete my thought in a complete manner" - that one was almost too complete
 
they need to grow up if that's the case :\
 
Sorry, I ment "they may not" referring to "the worst coder"
@RobertGrant XD
 
ugh, there really should be a function like Signature.bind that also binds default values...
 
Oh boy, I feel like I might regret asking but, why ?
 
Sorry I interrupted the convo what are we talking about?
 
10:03 PM
I'm struggling to normalize the function parameters - I have to manually insert the default values that were omitted
 
Ah, I have no idea what you are talking about... wish I could help.
 
wim
why do you care whether a default value was omitted or taken as default
it should make no difference ever
 
We're talking about how lru_cache handles default args.
 
TIL this exists. Rant over
 
YAY, the docs tho... needs a revamp.
 
wim
10:06 PM
why would lru_cache care about default args at all?
it only cares about what is passed to the function
 
That's exactly the problem. lru_cache has cache misses because of default parameters
 
wim
as it should!
because default parameters can be modified dynamically
 
...why though
 
@wim Because it can cause cache misses, as Rawing's example shows.
 
And if the result is rather large, additional space taken up in the dict
 
wim
10:09 PM
if that's an issue, don't use default arguments
 
Well, that's one way to solve it
 
wim
or, default them to None and set it in function body
 
@wim OK, but I expect that to be pretty rare. OTOH, it's also rather unusual to call a function that's using lru_cache with multiple signatures.
 
wim
or do this:
>>> def func(arg=1):
...     return _func(arg)
...
>>> @lru_cache
... def _func(arg):
...     ...
 
[jumping through hoops intensifies]
 
wim
10:13 PM
I dunno, I think re-engineering cache decorator will come back to bite you somehow one day
 
rubarb
 
How about giving lru_cache a keyword arg to tell it to always apply default args if they haven't been passed explicitly? So without that arg you get the current behaviour.
 
Or in order to reduce overhead, define a new function with a cachy name
(I'm not serious, I just wanted to cache in that lousy pun)
 
wim
bit of a stretch ... how do hungarians pronounce cache?
 
kesh
so...like "cash" :(
 
wim
10:22 PM
ah
 
I know it originates from French where it should be ~kush
 
ok, I can't lie, the 2nd pun made me giggle.
 
I never thought to check the proper pronunciation
well the first here says cash forvo.com/word/cache, the third one says kaysh
based on that comprehensive sample, US says cash, Aussies say kaysh, CAN says kush
 
wim
I thought CAN would say cash-eh?
 
well there's only the one Canadian pronunciation on forvo, and I'm sure it depends on regions too
 
wim
10:25 PM
(sorry...it was also a bad pun)
 
yeah, I realized now :D
 
wim
cash-eh would actually be closest to the french origin (cacher) though
 
I was about to explain that every sample on forvo has a single syllable, then I facepalmed
Or is this a loan word imported from French into English being read by French in English?
 
That feeling when you misunderstand a question and write an incorrect answer, and no one realises it, and hence upvotes. And then OP accepts your answer, and only after do you realise your answer is wrong. So you have to sit and correct your answer, because you can't even delete it.
And you're also morally obligated to notify OP that your answer is wrong, but it's been 6 months since OP last logged on, and you're afraid your faulty code has gone into some production environment, potentially costing the company millions.
 
all other things aside, it's not your fault if somebody uses code from SO without checking/testing/reviewing it
 
10:29 PM
Makes me feel a bit better :)
 
@cᴏʟᴅsᴘᴇᴇᴅ Hope you are not the reason behind Intel's stock meltdown ;)
 
fr.wiktionary.org/wiki/cache says \kaʃ\ is French (*giggle* backslashes in French IPA), \kæʃ\ is English cache
I'm nearing cacheception
 
Hah, I might be, if that code came from SO
 
Interesting. <-- Alien Programming (at least most of them)
 
DSM
11:19 PM
@Andras: I've never heard anyone say anything but "cash". I'm not good with French tech terms (idjaw once told me that they tend to use the English expressions rather than the textbook translations I'm familiar with.)
 
neat, thanks
rhubarb
 

« first day (2641 days earlier)      last day (2310 days later) »