I am working on a python script, which requires reading values from a list in for loop and performing some operations on it. currently it looks like this:  for i in someList:     # do some operation here   Now, this particular operation takes hours to complete, so what i want to be able to do is use multi-threading/sub-processes and process multiple items in parallel. So is there a way that I can run the for loop like:  for i,j,k in someList:     #do some operation here   i know this syntax can be used to iterate over multiple lists simultaneously, but I want to be able to use multiple items of the same list. What i want from the loop is that the value of i,j and k update in the following manner:  i = someList[1], j = someList[2], k = someList[3]   in the next iteration:  i = someList[4], j = someList[5], k = someList[6]
I have a Python script which takes as input a list of integers, which I need to work with four integers at a time.  Unfortunately, I don't have control of the input, or I'd have it passed in as a list of four-element tuples.  Currently, I'm iterating over it this way: for i in range(0, len(ints), 4):     # dummy op for example code     foo += ints[i] * ints[i + 1] + ints[i + 2] * ints[i + 3]  It looks a lot like &quot;C-think&quot;, though, which makes me suspect there's a more pythonic way of dealing with this situation.  The list is discarded after iterating, so it needn't be preserved.  Perhaps something like this would be better? while ints:     foo += ints[0] * ints[1] + ints[2] * ints[3]     ints[0:4] = []  Still doesn't quite &quot;feel&quot; right, though.  :-/ Related question:
How to download packages from a command-line given repository? Multiple disks vs single disk on virtualized environment We're planning to install a SQL Server on this physical architecture:  A hyper-v cluster based on windows server 2019 A cluster shared volume where all VMs live A full-flash SAN that contains the CSV  I've always read that is a common best practice to have multiple disks for data files, log files, temp db files ect... But that best practice is referred to a bare-bone installation. So, what I'm asking is: what are the actual benefits of doing so on the above described architecture (if any)? How can I better optimize my tables and a LEFT JOIN query to find items that don't yet exist in the right table? I have two tables that represent a list of urls and their related word indexes. Here are the table definitions for reference.  desc urllist; +-------+---------------------+------+-----+---------+----------------+ | Field | Type                | Null | Key | Default | Extra          | +-------+---------------------+------+-----+---------+----------------+ | id    | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment | | url   | text                | NO   |     | NULL    |                | +-------+---------------------+------+-----+---------+----------------+   and  desc wordlocation; +----------+---------------------+------+-----+---------+-------+ | Field    | Type                | Null | Key | Default | Extra | +----------+---------------------+------+-----+---------+-------+ | urlid    | bigint(20) unsigned | NO   |     | NULL    |       | | wordid   | bigint(20) unsigned | NO   |     | NULL    |       | | location | int(10) unsigned    | NO   |     | NULL    |       | +----------+---------------------+------+-----+---------+-------+   The software app is a web spider. It crawls a list of urls, extracts those urls, and inserts these into the urllist table. Then, an indexer checks to see what urls have not yet been indexed, and then proceeds to index said urls.  Here is the query I am using to find items in the left table (urllist) that have not yet been indexed in the right table (wordlocation). This query is as suggested on the :  select * from urllist ul  left join wordlocation wl on ul.id = wl.urlid  where wl.urlid IS NULL;   As of this writing my test database has only 600 indexed urls, and the wordlocation table has 1.3 million rows.  However, my CPU is at 100%, and the longest I've waited to see if the query would complete is a half hour (which, it never did by the way).  To be thorough, here is the explanation of the query:  explain select * from urllist ul left join wordlocation wl on ul.id = wl.urlid where wl.urlid IS NULL; +----+-------------+-------+------+---------------+------+---------+------+---------+-------------------------+ | id | select_type | table | type | possible_keys | key  | key_len | ref  | rows    | Extra                   | +----+-------------+-------+------+---------------+------+---------+------+---------+-------------------------+ |  1 | SIMPLE      | ul    | ALL  | NULL          | NULL | NULL    | NULL |   50364 |                         | |  1 | SIMPLE      | wl    | ALL  | NULL          | NULL | NULL    | NULL | 1351371 | Using where; Not exists | +----+-------------+-------+------+---------------+------+---------+------+---------+-------------------------+   I need this query to finish in seconds, not minutes. Also, I'm worried about scalability. I have 40,000 unique urls that are waiting to be added to the index, so how do I take that into consideration with my table and query design? 400,000 urls?  Just a couple notes about my decisions on the current table structure.  I have no intention of stopping at 400,000 urls, but perhaps bigint(20) is a bit overzealous?   Url as text is for more practical reasons. I index a lot of Asian and other foreign language domains which do not appear as their equivalent Kanji or other characters in the database and frequently take more than 255 characters.  I'm using MySQL. I'm definitely open to suggestions as to better table and query design. Please let me know if I can provide more information. I run into this infinite product today. I don't have that much experience evaluating products therefore I don't have any idea of how to tackle this.   Here is the question. Evaluate (if possible) in a closed form the product:  $$\Pi = \prod_{n=1}^{\infty} \frac{1}{1+\pi^{{\large \frac{1}{2^n}}}}$$  The numerical value seems to be $\Pi= 0.534523$ which is very close to $\frac{\pi}{6}$ taking into account that $\frac{\pi}{6} \approx 0.523598$. In the mean time W|A evaluates it to $0$. I'm lost.   Can the community help?  Edit: Based on the answer we have two products. The product I asked tends to zero and the bonus product provided by @you're in my eye (thanks for that) is $\frac{\ln \pi}{\pi-1}$.   Thanks for the quick response. For which $n$ is the sum: $$\sum_{k=0}^{n}10^k$$ a prime number? Are they finite? There are many documentaries, forums, blogs and more dedicated to . I have been frantically searching for an answer to my question however none of my sources have clarity to the matter of hand. I would really love a clear explanation to: What exactly is Dark Matter? Please help me to have a clear understanding. Does anyone have an intuitive explanation (no formulas, just words! :D) about the "$n-1$" instead of "$n$" in the unbiased variance estimator $$S_n^2 = \dfrac{\sum\limits_{i = 1}^n \left(X_i-\bar{X}\right)^2}{n-1}?$$ Signed to unsigned conversion in C - is it always safe? Suppose I have the following C code.  unsigned int u = 1234; int i = -5678;  unsigned int result = u + i;   What implicit conversions are going on here, and is this code safe for all values of u and i? (Safe, in the sense that even though result in this example will overflow to some huge positive number, I could cast it back to an int and get the real result.) "Which" vs. "what" — what's the difference and when should you use one or the other? Algorithm to match one input file with given numbers of file Adjective for someone who exaggerates emotions to get sympathy What's the word for someone who tries to get sympathy from others by exaggerating their emotions or constantly reminding them of something tragic that happened to them?  I'm looking for an adjective - no disorders or health related definitions please. How can I check dependency list for a deb package Creating a copy of primary database and attaching the copy database in the same sql instance I just got into a project in which we have only one SQL Server 2012 copy. We have 12 databases attached to the primary instance of SQL Server 2012.  As I don't have SQL Server 2012 or supporting OS, I have to depend on the primary instance of SQL Server 2012.  I am not sure whether it is good to create copy/clone of all 12 databases and attach it to same instance and work on the copy for data manipulation and query testing purpose.  Based on Kin's query  SELECT    SERVERPROPERTY ('MachineName') AS PhysicalMachineName,    SERVERPROPERTY ('ServerName') AS SQLServerName,    SERVERPROPERTY ('Edition') AS ServerEdition,    CAST(SUBSTRING(@@Version,charindex('SQL',@@version, 1),15) AS VARCHAR(255)) +  ' + '         + CAST (SERVERPROPERTY ('productlevel')AS VARCHAR (50)) + ' + (Build'        + CAST (SERVERPROPERTY ('ProductVersion') AS VARCHAR (50)) +')' AS ProductVersion,     RIGHT(@@version, (Len(@@Version)-charindex('Windows',@@version, 1))+1) AS [O.S.],  SERVERPROPERTY ('Collation') AS Collation   Following is the output. I ignored PhysicalMachineName and SQLServerName.  ServerEdition : Business Intelligence Edition (64-bit) ProductVersion : SQL Server 2012 + RTM + (Build11.0.2100.60) O.S.           : Windows NT 6.1 &lt;X64&gt; (Build 7601: Service Pack 1)  Collation      : SQL_Latin1_General_CP1_CI_AS A probability theory question about independent coin tosses by two players Say Bob tosses his $n+1$ fair coins and Alice tosses her $n$ fair coins. Lets assume independent coin tosses. Now after all the $2n+1$ coin tosses one wants to know the probability that Bob has gotten more heads than Alice.    The way I thought of it is this : if Bob gets $0$ heads then there is no way he can get more heads than Alice. Otherwise the number of heads Bob can get which allows him to win is anything in the set $\{1,2,\dots,n+1\}$. And if Bob gets $x$ heads then the number of heads that Alice can get is anything in the set $\{0,1,2,..,x-1\}$. So\begin{align}P(\text{Bob gets more heads than Alice})&amp;= \sum_{x=1}^{n+1} \sum_{y=0}^{x-1} P( \text{Bob gets x heads }\cap \text{Alice gets y heads }) \\[0.2cm]&amp;= \sum_{x=1}^{n+1} \sum_{y=0}^{x-1} \left(C^{n+1}_x \frac{1}{2}^{x} \frac{1}{2}^{n+1-x}\right)\left( C^n_y \frac{1}{2}^y \frac {1}{2}^{n-y}\right)\\[0.2cm]&amp; = \sum_{x=1}^{n+1} \sum_{y=0}^{x-1} \frac{C^{n+1}_x C^n_y}{2^{2n+1}}\end{align}   How does one simplify this?      Apparently the answer is $\frac{1}{2}$ by an argument which looks like this, Since Bob tosses one more coin that Alice, it is impossible that they toss both the same number of heads and the same number of tails. So Bob tosses either more heads than Alice or more tails than Alice (but not both). Since the coins are fair, these events are equally likely by symmetry, so both events have probability 1/2. Variance of Normal Order Statistics Suppose we have $X_1, \cdots, X_n \overset{\textrm{i.i.d.}}{\sim} \mathcal{N}(0, 1)$ with $n &gt; 50$, and let $X_{(1)}, \cdots, X_{(n)}$ be the associated order statistics. Are there any references pointing to formulas that specify (or estimate) the variance of the $k^{\textrm{th}}$ order statistic, i.e. $\textrm{Var}(X_{(k)})$, for $1 \leq k \leq n$? I am looking for formulas can be explicitly evaluated without resorting back to numerical integration.  I have seen this question: , which attracted a number of answers on approximate formula for the mean of the $k^{\textrm{th}}$ order statistic, e.g. Blom (1958) (and modifications based on work by Harter (1961) and Elfving (1947)). Searching on Google also yields a number of work on the variance / standard deviation for the $k^\textrm{th}$ order statistics for small $n$, all of them opting for a computation/tabulation route. They are: Godwin(1949), Teichroew (1956), and Parrish (1992). I have also attempted to derive something myself following the method sketched by @probabilityislogic in , along the lines of: $$\textrm{Var}(X_{(k)}) = \int_{-\infty}^{\infty} \left(x-\mathbb{E}(X)\right)^2 \frac{n!}{(k-1)!(n-k)!} f_X(x)[1-F_X(x)]^{n-k}[F_X(x)]^{k-1}\;\textrm{d}x,$$ with lower case $f$ denoting the PDF of a r.v. $X$, and upper case $F$ denoting the CDF. Noting $x = F^{-1}(F_X(x))$ and using the substitution $u = F_X(x)$ (with corresponding r.v. in upper case $U$), we have: $$\textrm{Var}(X_{(k)}) = \int_{0}^{1} \left(F_X^{-1}(u) - \mathbb{E}\left(F_X^{-1}(U)\right)\right)^2\,\mathcal{B}(u | k, n-k+1) \; \textrm{d}u,$$ where $\mathcal{B}$ denotes the PDF of a beta distribution (not the beta function). This can be rewritten as the variance based on the beta distribution: $$\textrm{Var}(X_{(k)}) = \textrm{Var}_{\mathcal{B}(u | k, n-k+1)}\left(F_X^{-1}(u)\right).$$ Approximating the RHS using (the variance bit of the) delta method, we get: $$\textrm{Var}_{\mathcal{B}(u | k, n-k+1)}\left(F_X^{-1}(u)\right) \approx \textrm{Var}_{\mathcal{B}(u | k, n-k+1)}(U) \cdot \left[(F_X^{-1})'\left(\mathbb{E}_{\mathcal{B}(u | k, n-k+1)}(U)\right)\right]^2,$$ where the prime denotes the derivative. The first term of the product is standard result. For the second part, given $(F^{-1})'(\cdot)=\frac{1}{f(F^{-1})(\cdot)}$ (see e.g. ), we then have: $$\textrm{Var}_{\mathcal{B}(u | k, n-k+1)}\left(F_X^{-1}(u)\right) \approx \frac{k(n-k+1)}{(n+1)^2(n+2)} \frac{1}{\left(f\left(F^{-1}\left(\frac{k}{n+1}\right)\right)\right)^2}.$$ Substituting in the standard normal distribution ($\phi$ for PDF, $\Phi$ for CDF) and scaling it to the desired variance $\sigma^2$ we arrive at: $$\textrm{Var}(X_{(k)}) \approx \frac{k(n-k+1)}{(n+1)^2(n+2)} \frac{1}{\left(\phi\left(\Phi^{-1}\left(\frac{k}{n+1}\right)\right)\right)^2},$$ which we can throw in a $\sigma^2$ term in front if it is not a standard normal. But surely someone must have derived that somewhere (again I am looking for some references), and there is a high chance that I have gone off track somewhere above. How to modify the space between the numbers and text of sectioning titles in the table of contents? I'm preparing a document using the book class. In the table of contents, the space between the subsection number and title is too wide. How to reduce it? How can I propose a new site? I have an idea or subject that should have a Q&amp;A, and want to propose a new site. How can I do this?  Related: character "5" repeated in text fields, and system freezes I am running Ubuntu 15.10, with the latest updates.  When I type in a text field (google search, type name of file, etc..) the number 5 gets typed on its own and it keeps repeating until I press ESC and when I try to continue typing the number 5 resumes filling in the text field.  I have tried to set the keyboard repeat to zero, but does not help.  This does not happen all the time, sometimes if I shut down the computer it then behaves normally when I restart it, other times the computer becomes useless because I cannot type in any of the text fields.  Thanks Sal Ubuntu 18.04 - Dell XPS13 9370 no longer suspends on lid close This was working perfectly on 17.10 but after upgrading to 18.04 yesterday, when the lid is closed the screen turns off but doesn't suspend properly.  I travel around a lot and immediately noticed the heat (and battery draining) when taking it out of the travel case.  I've tried uncommenting these lines in /etc/systemd/logind.conf  HandleLidSwitch=suspend HandleLidSwitchDocked=suspend   and restarted but didn't make any difference. How to zero out a drive?