145 karma · joined January 21, 2010
[Source: I'm a mypy core developer.]
def f() -> "Bar": ...
instead of def f() -> Bar: ...
(This is normally used for forward references.) This makes it slightly less nice, but not a terrible workaround overall. def foo(n: int):
pass
def bar() -> None:
foo("123")
>> main: note: In function "bar":
>> main:4: error: Argument 1 to "foo" has incompatible type "str"; expected "int"You're right about the image, but the book is worthwhile.
[1] http://news.ycombinator.com/item?id=4509281
[2] http://www.ncbi.nlm.nih.gov/pubmed/2738212 (The book is not cited in the abstract, unfortunately, but I believe this is the correct study.)
(I'm not certain what "should" means in that sentence - a moral judgement? - but I'll interpret it as advice.) I think that this is excellent advice for some people, but poor advice for others. I don't think there is anything wrong, per se, with wanting to be the very best at something. There's just a trade-off: you can be happily excellent, or you can take a chance and be perhaps the best but most likely just unhappy. But this decision is, in my opinion, a personal one: happiness does not have to be the ultimate goal of life.
What can we do to stop things like this from happening again? There's clearly no quick-fix overnight solution, but there should be some set of actions we can take to slowly reduce/eventually eliminate this kind of violence. Any ideas?
Disclaimer: I've made minor contributions to Phabricator and will be making larger ones shortly.
benchmarking spark_mggcl
mean: 49.29483 us, lb 48.77776 us, ub 50.25594 us, ci 0.950
std dev: 3.495423 us, lb 2.140951 us, ub 6.373469 us, ci 0.950
benchmarking spark_ocharles
mean: 60.12347 us, lb 58.95586 us, ub 61.48084 us, ci 0.950
std dev: 6.434853 us, lb 5.529613 us, ub 7.824865 us, ci 0.950
The simpler version appears to be faster.(As an aside, is there something in particular you dislike about do syntax? I find that it often makes things more readable, though slightly more verbose.)
From your comment history, I speculate that you - like me - are a long-time reader and only an occasional poster. These posts stand out as being unusually negative. I'd urge you to strongly consider changing your tone (and perhaps deleting your posts in this thread). Don't let this one altercation drive you away from the community.
Best -- David
Out of curiosity, what are you referring to here?
Edit: Sorry if this comes off as overly didactic: I incorrectly assumed you were new. However, my main point still stands.
I'm not sure if you're making some subtle point here that I'm missing, but it is not the case that any of the elements of array will be accessed by that code if args.length is 0. If args.length is 0, then the exit condition (which is evaluated before entering the loop body for the first time) will be false, and the loop body will not be executed at all.
I haven't posted much, but I read HN regularly.