Taking engine weight into account for automobiles, electric cars have much lighter motors and the extra volume/weight can be used for batteries.
Consider 30l fuel capacity = 30kg of battery. Petrol engine is about 300kg, Electric motor about 30kg. So that's 270kg that could be used for batteries (and is in the Tesla). And since the batteries can be anywhere in the vehicle, there's a benefit to that too!
Ref: http://auto.howstuffworks.com/tesla-roadster.htm/printable http://en.wikipedia.org/wiki/Tesla_Roadster
Batteries like Chrome-Vanadium Flow Batteries can already be recharged just by filling a tank (http://en.wikipedia.org/wiki/Flow_battery).
The energy density is still a killer, though.
Also take into account that the transfer of energy is less efficient for diesel than for chemical batteries (more wasted as heat). So it's not quite as bad as the energy density would suggest, but still pretty bad.
Energy density of diesel: 45.4 megajoules / liter
Energy density of a lithium battery: 1.30 megajoules / liter
"Same weight/energy ratio" (using volume as a proxy for weight since the lithium battery does not have a energy density by weight listed) is 40x.
"Charge time" of a diesel engine is probably also 40x (to pick a number) faster than battery charging (e.g. several minutes vs. several hours).
Multiply the two together and you have three orders of magnitude between the two "ifs".
Ref: http://en.wikipedia.org/wiki/Energy_density