Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99755 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24574 invoked from network); 5 Jul 2017 08:23:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jul 2017 08:23:46 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.42 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.214.42 mail-it0-f42.google.com Received: from [209.85.214.42] ([209.85.214.42:37450] helo=mail-it0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 38/D8-15131-D02AC595 for ; Wed, 05 Jul 2017 04:23:43 -0400 Received: by mail-it0-f42.google.com with SMTP id m84so82175019ita.0 for ; Wed, 05 Jul 2017 01:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=qeSChnNwRj6J2NERj3rnjTJuFfAorI+3Nzu2Up9lS6A=; b=kkPmBgb72+RSe1yyVOjmxO/zylGq9z91smiZQ64kKCyTpMRmj1/SXfO5osx1xYeCvD xM0lSIncugU4ImdQUaN3GltwfUU53gy7xexDf2d6PhDPLwhR73zHIZ18uOayje5cKTec RCze9g/ujK32GVrHUNID/6Z7kL0RmwOKG60L39NkF4ymNqHQQe8daG+PtZFxriR8jZ+t w/jRb6hhlfjcd8Ns7mC5chRzd8QJYYlPzEaNKWbg+OnOXBvN4Zp3jk0quW0816yc59+8 0mOmNWsM9aYnwcBz0VoYEqFgtqDZ20+M4ooZqx3yeyDLk7L8S8/JGnJ8rv2HMT+AnExb o7NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=qeSChnNwRj6J2NERj3rnjTJuFfAorI+3Nzu2Up9lS6A=; b=n4b6DV3o2NrWNyUSFlyJRzbFki236R+fdr4Q+GO/8zHzSW5/3peFiOzGdzLqN3IgTb ZvTdM5XbQ86TaeEAVTNK/dizO9rA6LmpCHWc2yIiXD+6CDQ7GI+QaQOEhASWyAfEIOyz 3EXXScuDLLfFEJzRqKxmKzJB4KpTLMhCT+/zBou2RPfo/MYBw9bPKF/SO9OQvItAYO/w 4a8SsTf7IGM0xXnc3QrIaVtSgh1qDxWU/quXPW2YpFUQw11wGyIL2dQk4xuXWudNyhsn Tw293DwsdpdNXQqjf5tx8H9klunk8rjW/X9axzEXGVRr12d+Akx0WT9uxey/6y2G5/Dy +Bug== X-Gm-Message-State: AKS2vOxz2xIchYk/jYJVm8uGcju6fdJ7Sr/GwBiRZdLiMCC5umcZC3sh edAAaQjdenw2NSYVUu39IoVZLrgZHA== X-Received: by 10.36.6.137 with SMTP id 131mr40819917itv.28.1499243019342; Wed, 05 Jul 2017 01:23:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.33.4 with HTTP; Wed, 5 Jul 2017 01:23:38 -0700 (PDT) In-Reply-To: References: Date: Wed, 5 Jul 2017 10:23:38 +0200 Message-ID: To: tyson andre Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary="001a113f7ce6999b0605538db735" Subject: Re: [PHP-DEV] Exposing object handles to userland From: nikita.ppv@gmail.com (Nikita Popov) --001a113f7ce6999b0605538db735 Content-Type: text/plain; charset="UTF-8" On Wed, Jul 5, 2017 at 2:01 AM, tyson andre wrote: > There was a proposal back in 2015 to implement > a function spl_object_id(object $o) : int`, > which directly returns the object handle > (similar to `spl_object_hash`, but as an integer, not a string). > I'm interested in finishing implementing spl_object_id for php 7.2 > > I already have working code implementing spl_object_id() at > https://github.com/TysonAndre/php-src/pull/1 > The implementation XORs the object handle with the > exact same random bits that `spl_object_hash` would. > You can drop the masking. It was never effective at what it's supposed to do (hide memory addresses), but as this is the object ID only, it is completely unnecessary here. > Previous emails from 2015 can be seen here: > - https://marc.info/?t=143835274500003&r=1&w=2 > > Previous comment by a PHP maintainer in support of `spl_object_id()` > - https://marc.info/?l=php-internals&m=143837339210596&w=2 > > I'm unsure if an RFC is necessary. I have two pending questions. > I'm +1 on the addition and would be fine with including it without RFC, if there are no objections on internals. > - Can two objects can have the same object id > but different object handlers? > (e.g. iterators of some built in classes?) > I'm not familiar enough with PHP's history to be sure. > No: In PHP 7 this is not possible, which is also why spl_object_hash() no longer includes the handlers. > - Can the the largest object handle be larger > than the size of `zend_long` in 32-bit systems? > Only in the sense that it could theoretically wrap around to negative numbers. Of course those would still serve as IDs just as well. > Example places where this would be useful: > > 1. https://marc.info/?l=php-internals&m=143849841618494&w=2 > > 2. I also recently wanted to track a large number of (cloneable) > small sets of objects in an application that sometimes used a lot of > memory, > and the fact that arrays support copy on write helped save memory > relative to SplObjectHash if arrays and integer keys were used. > See https://github.com/etsy/phan/pull/729#issuecomment-299289378 > > - Tyson Andre (tandre) > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --001a113f7ce6999b0605538db735--