Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114707 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 55579 invoked from network); 3 Jun 2021 11:18:38 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Jun 2021 11:18:38 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5672E1804BE for ; Thu, 3 Jun 2021 04:32:08 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 ; Thu, 3 Jun 2021 04:32:07 -0700 (PDT) Received: by mail-wm1-f51.google.com with SMTP id 3-20020a05600c0243b029019f2f9b2b8aso3501152wmj.2 for ; Thu, 03 Jun 2021 04:32:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seld.be; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=jNOtDFJVCsI1dMxA3XG+D37mVSHHhrPvqg5qAG/rMwY=; b=nnFgFTvwyQUXtA0Fw27uXSFEd1+ET/vqAhDLjWQIUseQoDMOU7x7FL5YBgGEeCVpYK yiQj/BG5mYJtq0jmyrCorx5RkQfaB8FItgyFl3VgssDI4210TNQC8MawClRBwgNcuVg+ K6wB792IZogw1GxYQibII7sNMGjyMC7PTg33n+sZkziW1XZZquTbjCdeAMgDza/Ip03s AI4dBSBRMBqo8iF8H53wQQZgodx6vlC7nZ0JGOd+J872rZkb1UbCfTkwgKBhHHT9Yktr 8pStzqfgSYZzuJXgg7hH84JIyZlmqa4ECMuTcxjUH7nFfASFJJL/o8uop26EJ7lt8Py8 otsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=jNOtDFJVCsI1dMxA3XG+D37mVSHHhrPvqg5qAG/rMwY=; b=onILuhCnrCBWOpVxYaWA63OByzJk9Uk1iEOJVzsB50tryYLPZ/JOl+ITCWXKIXBhZk QmO9wSkDbvREDWEZ24fyIGUMkNLSs1Unie8RzfIG2rQIuRnV1YKNRtwLkx85MLrJUER4 EMnx6xQzhwNwRZqFdIVWIv1tyecTPsR2kXL2WD9ec2tK2bLH2BTDowkV4pifQMcqGolE ew8maFLh5KnMprErmfib2ZNJmgsvPn8f5JUKnur9DbCdkVBbeXIvTnbJlmRHaJs9gTLA 9wfnRH+n0hEOJ6eM2rVoGqTqViaTIA9xjxrbrTnlVDvfc1QY2K55a9ba8OLNwJL4wbnN lqgg== X-Gm-Message-State: AOAM5301ADcioW/jPmsnFdj772CSZMf4PnJfhkE2w7NMzRerhmKl4IN0 obbLDcEtK7z8/pZJWlX++rs6k6K4iLlyMg== X-Google-Smtp-Source: ABdhPJxDUefthJ8mwU1DNz3zaxKhkIP5JvD0UDqjAufiZu2jeOUinsj1QxFXPuGjE5kpii936Ijm6w== X-Received: by 2002:a1c:1b93:: with SMTP id b141mr25500125wmb.8.1622719922941; Thu, 03 Jun 2021 04:32:02 -0700 (PDT) Received: from ?IPv6:2a02:168:4b6e:0:5952:8a1d:6e95:633a? ([2a02:168:4b6e:0:5952:8a1d:6e95:633a]) by smtp.gmail.com with ESMTPSA id 6sm2562883wmg.17.2021.06.03.04.32.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Jun 2021 04:32:02 -0700 (PDT) To: Mike Schinkel Cc: internals@lists.php.net References: <761D99C1-4728-4EE8-95F8-44A240AE1473@newclarity.net> Message-ID: Date: Thu, 3 Jun 2021 13:32:00 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: <761D99C1-4728-4EE8-95F8-44A240AE1473@newclarity.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Subject: Re: [PHP-DEV] Regarding array_shift()/array_unshift() From: j.boggiano@seld.be (Jordi Boggiano) Hah, I sure did not expect my answer to trigger these 5 complex RFCs worth of work ;) On 03/06/2021 00:59, Mike Schinkel wrote: > > 4.) Given Nikita's comments on the O() performance of array_shift() have you considered instead simulating a FIFO queue using an array as a stack? Any reason that would not work for your needs? I think your analysis is overall on point. There are probably better data structures that could lead to me not needing array_shift in most places I use it. However arrays are quite the tool in PHP, and lazy as it may be they usually do the job well enough and the perf overhead of reindexing (which tbh I was not aware of until this thread) seems unnoticeable in most case (a quick test shows 1ms to shift a 300K item array on my loaded laptop, which is really quite acceptable). > So in summary the tangential topics I addressed were: > > 1.) PHP potentially supporting multiple return values, and > 2.) Renewed focus on SPL data structures. > > Again, if anyone is interested in these tangential topics and wants to discuss further, please create a new thread and quote my applicable comments from this email. To your other points: Multiple return values and SPL with better docs/naming/usability would absolutely be great to have from my userland perspective. Best, Jordi -- Jordi Boggiano @seldaek - https://seld.be