Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:59593 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54102 invoked from network); 10 Apr 2012 01:34:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Apr 2012 01:34:46 -0000 Authentication-Results: pb1.pair.com smtp.mail=mail_ben_schmidt@yahoo.com.au; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=mail_ben_schmidt@yahoo.com.au; sender-id=unknown Received-SPF: error (pb1.pair.com: domain yahoo.com.au from 72.30.238.202 cause and error) X-PHP-List-Original-Sender: mail_ben_schmidt@yahoo.com.au X-Host-Fingerprint: 72.30.238.202 nm37-vm2.bullet.mail.bf1.yahoo.com Received: from [72.30.238.202] ([72.30.238.202:23667] helo=nm37-vm2.bullet.mail.bf1.yahoo.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EB/99-34074-43E838F4 for ; Mon, 09 Apr 2012 21:34:45 -0400 Received: from [98.139.212.147] by nm37.bullet.mail.bf1.yahoo.com with NNFMP; 10 Apr 2012 01:34:41 -0000 Received: from [98.139.211.200] by tm4.bullet.mail.bf1.yahoo.com with NNFMP; 10 Apr 2012 01:34:41 -0000 Received: from [127.0.0.1] by smtp209.mail.bf1.yahoo.com with NNFMP; 10 Apr 2012 01:34:41 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com.au; s=s1024; t=1334021681; bh=vTrlI9b7i1mhdOEfxVaW8HNj6DaRRi4WwW9r8dt2htc=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Content-Transfer-Encoding; b=xa2kWIgOC2N8Q36YebxaSXI2t0hyNc63yUFrfHYsu8gVEM0D+FuZ28E0Dr//TGss5wMlu51t1lyOIYyoVSP7wwjwsglqbl5enwFdHk7wc3MN3OFJ+iWPp8YorrF+Aw36+yOjdiODjWaFrlPM68LsRZrmMVcHUA1OxtYt6WRRLsY= X-Yahoo-Newman-Id: 842664.74734.bm@smtp209.mail.bf1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: pnAI8lYVM1nFDj2CkMVuc_YNKRLn3i8h6ZbdjG5t1qA9XxJ l4xU57hId9vX_0iSPhecaXPPag1LMbdeUgPfd0T9H0E1jUBASQsR4E97bwze KIF1Cd0HckIdBBBxGqU5bhu6bLPVopWdOw5A6vUHE1Ge8eJcoDlvH3pr20M9 6KOeKLYI3pfZeA2.jMzaWMdEYR.nAYHAjHZXeIk3EMRwMtqLcWqRYl67b4py mR.qenwwgnfWx.tFmfk7dThBH9Kld.6BZoIHzMqgkE4urwE0zs7IQjnnbEsU xsWho_pMuqJ6YzbXfgQUOMcRsgZuA8hN5bn5RJGsv5qYbr0a8cqz42pJ5rwH EAVN2Muu0z05K57e0kbywHwEI1slpgERQS4b.HWMY3EsBoRS.gUthXRoFq2S m6J5VTI1FcBG9PFV0xuodHyoEc4AryqTPxmVGYhxQ2nx30OAB_zTdkFTb4_C UkVJrQSE- X-Yahoo-SMTP: enFMnPSswBAexaHyzgobwuUTrYOhZdJ0KRA2SjA- Received: from Thoughtful.local (mail_ben_schmidt@203.158.37.208 with plain) by smtp209.mail.bf1.yahoo.com with SMTP; 09 Apr 2012 18:34:41 -0700 PDT Message-ID: <4F838E2E.4040206@yahoo.com.au> Date: Tue, 10 Apr 2012 11:34:38 +1000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 MIME-Version: 1.0 To: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Traits and memory size From: mail_ben_schmidt@yahoo.com.au (Ben Schmidt) Hi! Just a quick question about traits. During the flattening process, is a copy made of the trait code (or bytecode or whatever)? So, if I have trait A { // a bunch of methods } class B { use A; } class C { use A; } class D { use A; } will I have four copies of A because it has been copied into all of the classes, and thus this aspect of my code will take up four times as much memory than if I did: class A { // a bunch of methods } class B extends A { } class C extends A { } class D extends A { } 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. Hope this is a simple question and won't take too much time for anyone to answer! Thanks! Ben.