During the flattening process, is a copy made of the trait
code (or bytecode or whatever)?
...
Or is the code shared so the memory use will be roughly the same?
...
I realise the use cases for traits and inheritance are
different, and often the situation will dictate the design,
but sometimes you have these two options so have to make a
design decision, and it would be nice to know the impact on
memory use/code size.
...
But the decision to use traits or inheritance should be pretty
obvious, and the amount of memory either way uses should be
irrelevant.
If either choice appears to be allocating too much, then it's the Zend
Engine itself that should be looked at, and not rewritting PHP code.

Not necessarily. There are design tradeoffs when implementing traits. It
may (or may not) be the case that there is a tradeoff between execution
time and memory use. The implementor may have perfectly good reasons for
favouring, say, execution time, even though due to my environment I may
be more concerned about memory use, and there's no real reason why he
should change, and not me.

Also from a purely practical viewpoint, rewriting PHP code may be more
feasible in the short term. :-)

At any rate, Stefan has confirmed that there isn't code duplication
behind the scenes, so it's not an issue!

Smiles,

Ben.




--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to