What is the rationale for the Lightning network's path length limit (20 hops)? A sender in the Lightning network can choose a path with up to 20 intermediaries (BOLT4).

Tor is another network that uses onion routing for anonymity. However, in Tor all paths have 3 intermediaries, and longer paths are explicitly advised against (source 1, source 2). The sources make a point that attacks mostly rely on compromising the first and the last nodes, and increasing the number of nodes in between doesn't improve anonymity, but increases latency. 

Do similar arguments apply to Lightning (maybe for path of slightly higher lengths but still under 20 hops)? Where does the number 20 come from? Would it be a good idea to decrease it?
The onion routing in Lightning is based on the Sphinx Mix Format described in this paper. The situation is different from Tor 


We don't have entry and exit nodes in Lightning as all nodes are inside the Network. 
In Tor a new connection along the path is as easy as creating a TCP socket between the tor routing nodes. In Lightning a payment channel with enough liquidity would have to be available and can't be spawn instantaneously.


The latter argument already calls for longer paths as nodes cannot just ask routing nodes to make certain hops. (That might change though if the trampoline network is coming to Lightning with which your Tor argument might hold.) Let us additionally assume I would always have paths of length 3 in Lightning. A routing node would basically see who paid whom as there are the incoming and outgoing HTLCs.

The main reasons for the Sphinx packet to be 20 hops are - as far as I understand - the following:


The per hop data is 65 Byte and with 20 hops it will always fit into a small TCP/IP package giving no clues for traffic analysis and timing attacks. 
We assume that the Lightning Network will still somehow be a small world network with a rather small diameter, so 20 hops should be sufficient.