Why is jQuery.ready recommended when it’s so slow?

To the point first: No, there is no disadvantage in calling you init before closing the <body>. It will as you have noticed perform better that relying on $.ready() and will also work with all the browsers flawlessly (even on IE). Now, there are however reasons to use $.ready(), which in your case they do … Read more

How can I force a subquery to perform as well as a #temp table?

There are a few possible explanations as to why you see this behavior. Some common ones are The subquery or CTE may be being repeatedly re-evaluated. Materialising partial results into a #temp table may force a more optimum join order for that part of the plan by removing some possible options from the equation. Materialising … Read more

Restrict scipy.optimize.minimize to integer values

pulp solution After some research, I don’t think your objective function is linear. I recreated the problem in the Python pulp library but pulp doesn’t like that we’re dividing by a float and ‘LpAffineExpression’. This answer suggests that linear programming “doesn’t understand divisions” but that comment is in context of adding constraints, not the objective … Read more

Why does clang produce a much faster code than gcc for this simple function involving exponentiation?

From this godbolt session clang is able to perform all the pow calculations at compile time. It knows at compile time what the values of k and n are and it just constant folds the calculation: .LCPI0_0: .quad 4604480259023595110 # double 0.69999999999999996 .LCPI0_1: .quad 4602498675187552091 # double 0.48999999999999994 .LCPI0_2: .quad 4599850558606658239 # double 0.34299999999999992 .LCPI0_3: … Read more

Don’t use StringBuilder or foreach in this hot code path

I made the code change and yes it made a huge difference in number of allocations (GetEnumerator()) calls vs not. Imagine this code is millions of times per second. The number of enumerators allocated is ridiculous and can be avoided. edit: We now invert control in order to avoid any allocations (writing to the writer … Read more

How many resources will a browser download from a given domain at a time?

Nicely answered in this – thread IE7 allowed only two concurrent connections per host. But most browsers today allow more than that. IE8 allows 6 concurrent connections, Chrome allows 6, and Firefox allows 8. So if your web page only has 6 images, for example, then it’d really be pointless to spread your images across … Read more

How can I optimize this Python code to generate all words with word-distance 1?

If your wordlist is very long, might it be more efficient to generate all possible 1-letter-differences from ‘word’, then check which ones are in the list? I don’t know any Python but there should be a suitable data structure for the wordlist allowing for log-time lookups. I suggest this because if your words are reasonable … Read more

Is the compiler allowed to optimise out private data members?

Possible in theory (along with unused public members), but not with the kind of compiler ecosystem we’re used to (targeting a fixed ABI that can link separately-compiled code). Removing unused members could only be done with whole-program optimization that forbids separate libraries1. Other compilation units might need to agree on sizeof(foo), but that wouldn’t be … Read more