« first day (5079 days earlier)      last day (89 days later) » 

07:42
@sezanzeb Thanks for that! I did find that if you have an input() invocation at root level then the unit tests stopped working because importing would wait for input. At the time, I just commented out that part of the code (leaving just the function) wrote the unit test, then after I was finished, I uncommented it. But that's much nicer, since I can both run the unit test and have the file for submission to the online judge thing.
08:09
@VLAZ Don't call that "importing", call it "reading from stdin", which is what it is. (In Python, importing is what you do with packages, not I/O). Anyway, your issue is that by default, reading input from stdin is buffered, but you want unbuffered input. See these.
@smci No, by importing I mean from my_file import my_function which I did in the unit test (separate file). And if there is an import() at the root level in my_file, then the unit test waits forever for input from stdin which never comes. Therefore, the test doesn't run.
@VLAZ Please start Python with stdio buffering disabled like I suggested and confirm if that doesn't fix this?
@smci If you have input() in top level call, this will be run on import of the script and block. I don't think this has anything to with buffering.
I'll have to try later, since I'm on a different machine right now. But I'm not sure buffering is the culprit.
08:56
github.com/google/atheris/issues/94 - I think I've found a bug or interesting limitation of atheris
I'm interested in seeing if others would have an opinion on that?
@VLAZ yeah, this is why if __name__ == "__main__": is being commonly used in python.
So that you don't have any code at the root level that gets executed when your file is imported. You could, for example, write a def main() method that can be imported, and call it in that in that if. When you import that file in your test, you can call main() once your patches/mocks are set up. Or, when you run that file using python3 file.py, it will be run directly.
09:15
@sezanzeb Yep, that's what I ended up doing in the end. Thanks for the tip!
 
4 hours later…
13:01
morning cabbages, folks
 
2 hours later…
14:46
@sezanzeb BTW, "method" isn't a synonym for "function". All methods are functions, but not all functions are methods. A method is a function which is an attribute of a class.
 
3 hours later…
17:21
My first actual intro to mypy: kthxbye. I wouldn't mind so much if I didn't absolutely have to have this code run tomorrow, and now I have to satisfy pre-commit hooks on things I absolutely never expected to even throw. Let's hope my laptop doesn't blow up overnight because I ain't trudging through this in one night for version control. I've rapidly gone from indifferent to not-a-fan
 
2 hours later…
19:42
What libraries/modules/headers do things fastest ?
The ones written in C or rust
Thought that. Currently closed a ( my) question like that as too broad. Can well tuned python compare ( since most things are if/else and goto/recursion ? )
Not really. Though there may be libraries where the difference isn't large enough to matter
I know isprime can be defined as 4 cases 2,3,then 5 mod 6, and 1 mod 6 with adds instead of increments you can make a forprime loop based on it
I've talked to people knowledgeable about asm and worked a bit on PARIDroid ( PARI/GPapp for android) but I'm clueless on libraries/modules/headers
Okay others wrote the behind the scenes code but some came from me requesting them
Logic gates that weren't double pass makes things faster( 20% boost over double pass up to roughly 80 million)
Sorry what was the topic before me interupting ?
20:27
For those wondering try My answer to On average, how much faster will a program run in C++ vs. Java (same hardware)? quora.com/…
20:42
Reason I bring this up is python may use double pass so bad practices can speed it up
21:13
The goal in any language is to minimize $$\sum_{i=1}^n c_it_i$$ where $c_i,t_i$ are the ith conditional checks and average time per check. In any code using double pass, it goes through the whole of the checks on each input so you end up linear in time. single or lower pass uses checks that the not wanted data points fail early. If conditions sieve huge chunks of unwanted data quickly, it can make up for the extra overhead of nesting conditionals.
Don't worry, 3 hours and I'll likely be off for the night...
@roganjosh needs help ?
Okay sorry. I'm a lunatic
Single pass or less now allows order of checks to matter
21:39
I honestly think it's time for you to take a break for this evening (assuming it's evening where you are). You will not ingratiate yourself with this splurge and calling yourself a lunatic
Okay sorry. I just like conversations
Conversations are fine but that's not really what's happening here. You've jumped into a community of experts and then just gone on a tangent to tell us about language design. That's not a conversation; it's a lecture. You are welcome here but I would tone down that side of "The goal in any language is to minimize [...]".
I'm more on the theory of optimization. In any interpretted or double pass logic languages gain from theory.
But what is your point? Your posts are just statement of opinion from left-field. You don't ask any questions beyond the first point and then just tell us how languages are designed. What response do you expect from that? That's not a "conversation"
21:55
It does as double versus single pass logic applies.
The reason the nested conditionals win, is because PARI/GP uses double pass logic historically.
No it doesn't. I'm actually trying to be mild on you because I've been told I'm too "pissy" but you're pushing it here. How is a comparison of C++ and Java at all relevant to python?
If python has interpretted and double pass logic it gains from the same theory PARI/GP ( a C library/console) does in my examples
Welp, I'm off to bed. It gives me rest and absolves me of wondering whether my moderation has been too harsh by leaving it be. I don't understand your point - it seems like self-promotion of some strange idea to me - but at least I'll sleep. rbrb
22:35
Comparing speeds is pointless I guess
26% battery left but I'll leave for now

« first day (5079 days earlier)      last day (89 days later) »