If the process is irreversible, the pressure of the gas within the cylinder is not uniform, and varies with spatial location. The force per unit area at the piston face (where the work is being done) $\sigma_f$ is also affected by viscous stresses (which are not present if the process is reversible). So, in an irreversible process, the work done by the gas on the surroundings is given by $$W=\int{\sigma_f dV}=\int{P_{ext} dV}$$ where $\sigma_f$ is the compressive stress exerted by the gas at the piston face. This compressive stress includes the thermodynamic pressure $p_f$(evaluated at the local gas specific volume and temperature, as, for example, calculated from the ideal gas law) plus a viscous stress, determined by the local rate of gas deformation in the vicinity of the piston face: $$\sigma_f=p_f+\sigma_{vf}$$Note that, from Newton's 3rd law, the compressive stress $\sigma_f$ exerted by the gas on the piston face is equal to $P_{ext}$, the compressive stress exerted by the piston face on the gas.
If the process is carried out reversibly, then the viscous stresses are negligible, and the thermodynamic pressure is uniform throughout the gas, such that$$\sigma_{vf}=0$$ and $$p_f=p$$where p is determined from the total volume and temperature of the gas, as, for example, from an equation of state such as the ideal gas law. So, for a reversible process, $$\sigma_f=P_{ext}=p$$ and $$W=\int{P_{ext}dV}=\int{pdV}$$
Here is a link to an article I wrote that explains the difference between reversible and irreversible gas expansion (and compression work) in terms of the close analogy to a mechanical spring-damper system: https://www.physicsforums.com/insights/reversible-vs-irreversible-gas-compressionexpansion-work/
In a quasistatic process (reversible), the difference between the external pressure and the internal pressure is infinitesimal for each infinitesimal change in the volume of the system.
$P_{ext}=P_{int} \pm dP $,
As you know that the term for work in terms of pressure is given by, $dW=PdV$. This means that work obtained will be maximum if the pressure is maximum for each infinitesimal change in volume.
In a reversible process, the work done in each step obtained is maximum since the external pressure in only infinitesimally greater (or smaller) than the internal pressure.
This enables us to connect the internal pressure and external pressure (since they are almost equal) using the ideal gas law, which in turn enables us to derive work in terms of volume change, without knowing the pressure.
$P_{int}V=nRT$
$W_{int}=\int_{v_1}^{v_2} P_{int}dV$
$W_{int}=nRT\int_{v_1}^{v_2} \frac{dV}{V}$
For non-reversible process, such thing is not possible. This process is instantaneous. Internal pressure won't have enough time to become almost equal to external pressure. Only, external pressure is a way to find the work. The work done by internal pressure and external pressure are equal in magnitude. For some processes, external pressure is given. We can either simply calculate the work done by using external pressure and volume change or use to ideal gas equation to remove the pressure term. But the latter is won't be possible, since you do not know how the internal pressure is changing. In case of reversible processes, you had the ideal gas equation to give you a relation between pressure and volume.
Hence, we use the constant external pressure (when you put a weight on the piston you get constant external pressure) to calculate the work.
Therefore, for non-reversible processes,
$W=P_{ext}(V_f-V_i)$
Moreover, work done by a particular pressure is not $\Delta P dV$. For instance, when there are two forces acting on a body the work done by a particular force is not given by the the work done by the net of the two forces but instead the work done by a particular force is given by that force's magnitude and the displacement of the body in that force's direction.
Best Answer
The work done by an expanding gas is the energy transferred to its surroundings. In effect, as the gas expands it is compressing its surroundings so the work done is the force exerted on the surroundings (i.e. the pressure of the surroundings times the area) times the distance moved.
The extreme case of this is a Joule expansion where a gas expands into a vacuum i.e. the pressure of the surroundings is zero. In this case the expanding gas does no work regardless of the initial pressure of the gas.