Fast Creation Of stdClass Objects¶
The fastest way to create a stdClass object is to create an array, and then cast it to stdClass with the (array) cast operator. It is still faster even if the array is build piece-meal: two times slower.
Setting directly properties on the stdClass object is then about three times slower, and creating a class extension with an adapted __construct method is then four times slower.
In the end, this is a micro optimisation.