The P 31 was a passenger locomotive that was a development of the standard design P 2. It must not be confused with the P 3, which were different locomotives that were only combined under a common designation.
The intention was to increase the power of the boiler while keeping the dimensions the same. To do this, the pressure was increased from ten bars (145 psi) to twelve bars (174 psi) and a larger grate surface was introduced in order to increase the evaporative capacity. A special feature of this boiler was the strong inclination of the grate, which was already evident when looking from the outside. The higher pressure allowed the cylinders to be downsized in both dimensions to achieve better efficiency. Their diameter decreased from 420 to 400 mm and the piston stroke from 600 to 560 mm. In addition, the diameter of the driving wheels was increased in order to reduce their rotational speed at line speed. The power was sufficient to pull 93-tonne trains at 80 km/h and 200-tonne trains at 58 km/h on the level. On a gradient of one percent it was still 125 tonnes at 35 km/h.
The Prussian State Railways procured a total of 597 of these locomotives between 1884 and 1897. Since each directorate had its own numbering, the number range from 1601 to 1700 was sufficient. Several other railways ordered identical or at least approximately identical machines in smaller quantities, with production of these even carried on until 1907. The other operators were the Royal Prussian Military Railway, the Holstein Marsh Railway, the Main-Neckar Railway, the Dortmund-Gronau-Enschede Railway, the Lübeck-Büchen Railway and the Mecklenburg Friedrich-Franz Railway.
Only twelve units from the Prussian stock made it into the Reichsbahn's provisional renumbering plan, but all of them met the same fate as a large number of other older locomotives: they were retired until the actual renumbering in 1925. The only P 3s that made it to the Reichsbahn were 22 of the original 39 engines from Mecklenburg. They were among the last built and were given the numbers 34 7301-7308 and 34 7351-7364. The two number ranges had their origin in different axle loads of about 12.5 and 13 tonnes. During this time they were only used for shunting and were retired by 1930.