Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112679 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 94337 invoked from network); 30 Dec 2020 20:02:02 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Dec 2020 20:02:02 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BEB2C1804D4 for ; Wed, 30 Dec 2020 11:36:48 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 30 Dec 2020 11:36:48 -0800 (PST) Received: by mail-qk1-f179.google.com with SMTP id b64so14736973qkc.12 for ; Wed, 30 Dec 2020 11:36:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=sW0aioFNk5hCNGrfN2X3Ww78rvXVU1eI8rMLuvf378o=; b=uKZsfjUJlEBaF86LPf/yk/aTHU+bst6kPdAXVrnMccdvJspVmIk2brHG7Yi6CpJgYM cOmoNdNBdV+8GLVo7NFNcF1A/clCITOqCIvBnrjzz+8vbVNrfdwSSMmCPTpEPQw1iFO0 tGNtTQyC0ErY0dTLS0Het+01beKeJFHboM97JOqNoY/n5xcmm1h4qfwwY5pFyC9x5nMx HysBcltXdxbXHU4n1xSOxrFJF/UWfReceSDaoCbfxQ9YdhE2j/tfiDXHwu8AG/31xQgL eFCkCYUM2Dr/CvaoEOhkuSV2IuBhQZHgT4xsRXt+6c/pQlBd634fzQOqFC0qop9Gnvy3 di2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=sW0aioFNk5hCNGrfN2X3Ww78rvXVU1eI8rMLuvf378o=; b=EJ9s9I1X2drVS6kcf5NsDP2OhvHQfpmWr7Yuejq8nvENAEj6ALVQZN3D9yC3Yc7g5E UGkigJVqyxDzFNJjZWZpYj18O78gG04uOaV9wPux1J+yKKFjxTxwE6+loEJVNHkk28uU +H5GuKE/K4XzHuPC644DEzdV8yrVnS7N1ssTWHMzhwiHoftIx61+2eVZsFaRQ3IcO4PZ ntMll5FGOF8h4/VBAdhINepO6GD1dludjNtphTYdCbv37jmveWoH7pA5O01uOh5Uh6wS zMKPeTBr7rTnFLDkwm6JRxFG2siVeObiX6xivHmD6L7876hKRHoa66bCRFzvvPHxZBSy EDew== X-Gm-Message-State: AOAM532Zsi96X5wfBKk4AcRZ7J7ptU6SumzpioJUh4xKZQNKWfEQAuhe 6cAbl7F/4DpvImzZTlRdPZ1WAYk6DJZjirLOWQc= X-Google-Smtp-Source: ABdhPJxVk3EJaqyv+RUO0dz9GR3j6Ao+AKHC/N3J+SfYz2PcB7WPAx+z9d5ZlAR7JLrOCdBOIOWdR49fw5zI87V5CPI= X-Received: by 2002:a37:bcc6:: with SMTP id m189mr55063352qkf.88.1609357006524; Wed, 30 Dec 2020 11:36:46 -0800 (PST) MIME-Version: 1.0 References: <1d0abb04-4987-43a9-85bc-bccc3bd6be9a@www.fastmail.com> <03108284-740a-4a5d-130f-15b2e67e9df9@mabe.berlin> <459d7ff7-e553-dce9-7d43-c3b1e772e572@gmail.com> <7f4fe9ca-1c20-6f69-cef0-a9718af742a3@gmail.com> <3e683903-66cb-4a1a-9ff8-22887dbb8dce@www.fastmail.com> In-Reply-To: Date: Wed, 30 Dec 2020 12:36:30 -0700 Message-ID: To: Larry Garfield Cc: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Analysis of property visibility, immutability, and cloning proposals From: cja987@gmail.com (Chuck Adams) On Wed, Dec 30, 2020 at 12:27 PM Larry Garfield wr= ote: > > If you clone the object, you don't duplicate 15+1 zvals. You duplicate j= ust the one zval for the object itself, which reuses the existing 15 intern= al property entries. If in the new object you then update just the third o= ne, PHP then duplicates just that one internal zval and modifies the new on= e. So you still are using only 18 zvals, not 36 zvals. (Engine people: Ye= s, I am *very* over-simplifying. I know.) > I've pondered hacking in something like perl's bless() to turn arrays into value objects, but according to this it looks like an object with clone-on-write behavior would be better, as I'm assuming arrays do a full shallow copy: given an array of 15 entries, pass it to a function, change one member, now you're using 15 more zvals, as opposed to just one with an object. Am I reading that right? --c