The pressure-volume work in thermodynamics The change of pressure-volume work is given by: 
$$\delta W = P\mathrm d V$$
Where $P$ denotes the pressure inside the system [1].
I wonder why the work is not given by:
$$\delta W = (P-P_{ext})\mathrm d V$$
For me this last expression is more logical, for instance if $P = P_{ext}$ then there is no mechanical work.
Can you explain please?
 A: With your idea the $piston$ would be accelerating all of the time and some of the external work would be used to increase the kinetic energy of the "piston".
This idea crops up a lot in Physics.
You have a piston with a force of magnitude $F$ acting on a "piston" area $A$ due the gas pressure $P$.
To keep the piston from moving you need to apply an external force of magnitude $F'$ in the opposite direction to force $F$ and also make $F'=F$.
You now want to evaluate the work done by the external force in moving the piston.
This you can look at in a variety of ways.  
You apply a slightly larger force $F'' >F$ on the piston just to get the piston moving (and give the piston some kinetic energy) and then once the piston is moving apply a force $F'$ on the piston which will now keep moving at constant velocity as the net force on it is zero.
All this time force $F'$ is doing work compressing the gas.
Just before the end point you reduce force the force on the piston to $F'''<F$ so that there is now a net force slowing the piston down and just as you reach the end point the piston stops moving having lost its kinetic energy and you apply a force $F'$ on the piston.
The total work done on the gas and piston is the work done by forces $F', F''$ and $F'''$ but there is a net zero amount of work done on the piston because it starts and finishes at rest.
However the net work done on the piston is zero because the extra bit of work which was done on the piston starting it was "given back" when the piston was slowing down at the end.
So the total work done on the gas was $F'\Delta x=F\Delta x=PA\Delta x= P \Delta V$
Or you could have the piston moving very, very very slowly from the start and evaluate the work done on the  gas by the constant external force $F'$.  
Or you could just evaluate the work done on the gas a $P\Delta V$ and assume an infinitely slow change of volume..
A: The formula for irreversible expansion work does not apply during the expansion process. Instead of the “external pressure” $P_{ext}$, the pressure $P_{sys,mb}$ on the piston or other moving boundary (hence the subscript mb), which is nearly equal to the system pressure $P_{sys}$, should be used in the integral over volume. This formula only requires that $P_{sys}V$ and $T$ are well defined, that is, a system of uniform $P$ and $T (“uPT”)$ undergoing a “$uPT$ process”, which may be irreversible.
An instructive example is an expanding gas accelerating a bullet horizontally and performing work without a conventional external pressure. It must be emphasised that $δw = −P_{sys,mb}dV ≈ −P_{sys} dV$ is the only useful formula for infinitesimal $PV$ work during a $uPT$ process.
The quasistatic approximation $P_{sys,mb}= P_{says}$ and $δw = −P_{sys} dV$ is usually excellent and enables analyses of irreversible $uPT$ processes, for example, in heat engines; friction in the surroundings and a large piston mass improve the approximation. Slow chemical reactions at constant $T$ and $P$ are quasistatic, and many equations in advanced chemical thermodynamics apply specifically to $uPT$ or quasistatic processes. The equality $dS =\frac{ δq_{irr}}{T}$ applies in irreversible quasistatic processes without composition change. 
In short, with well-defined $P $ and $T $ at constant composition, the simple equations for reversible processes are usually excellent approximations even when the process is irreversible.
However according to your last statement:

For me this last expression is more logical, for instance if $P=P_{ext}$ then there is no mechanical work.

Let me define the work done to move an object against an opposing force:
$$\boxed{\delta w=-P_{ext}dV}  \tag{1}$$
The work arising from a change in volume is known as expansion work. This type of work includes the work done by a gas as it expands and drives back the atmosphere. It also includes work associated with negative changes in volume, I.e., compression. Other types of work don't involve changes in volume, like electrical work, are called non-expansion work or additional work. The work done by a system as it expands by $dV$ against an external pressure( work of expansion) is given by equation 1.
While in a reversible expansion, is the change that can be reversed by an infinitesimal modification of a variable. A condition in which an infinitesimal change in a variable in opposite directions results in opposite changes in its state is called equilibrium state. To achieve such an expansion, the external pressure is set equal to the pressure of the gas p at each stage of the expansion. Then, 
$$\boxed{-\int_{V_{i}}^{V_{f}}{pdV}}$$
But when the system expands into vacuum, no work is done since system expands freely against zero external pressure, unlikely what you have mentioned. Hence $w=0$ since $p_{ext}=0$,and not because $p=p_{ext}$ as that would be a case of reversible expansion.
