Fast Creation Of stdClass Objects

no-email (Damien Seguy), Damien Seguy
Thu, 06 Oct 2022 00:00:00 +0000

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 peacemal (2 times slower).
Setting directly properties on the stdClass object is then about 3 times slower, and creating a class extension with an adapted __construc method is then 4 times slower.
In the end, this is a micro optimisation.