Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112640 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 35316 invoked from network); 29 Dec 2020 17:38:01 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Dec 2020 17:38:01 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B377A1804C4 for ; Tue, 29 Dec 2020 09:12:30 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) (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 ; Tue, 29 Dec 2020 09:12:30 -0800 (PST) Received: by mail-ot1-f53.google.com with SMTP id 11so12349091oty.9 for ; Tue, 29 Dec 2020 09:12:30 -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; bh=Mj/xWhImLzf051Pq2tN2kXqsjTfE6EsHHZj4p3G/stM=; b=uhKHBd9Tsg3PmpnDi0EZgfyNXQz7y+Hu48GLd7HclczWpBgIK+H3UppbmKQ80TTxVo 0f7x2ZduEeEVT520FmoLF5RWrQY2pCLLT7Kdc9ac6IT27OdT7MOgBcG992gs5tuM/MG8 HhYm7prpTWPN5SGtzFwIK6LL4YeiY9az+t5vZWLyXu0Z4GO4/3WjslOsB+4Xpce34OHC kXeN1iLvg1DS7xMwRQUib0WT0awp4SJRNb9VZb8lucd4KH8dQ67nj2CUfYeOb/Tku4V0 vx050zHwzMpOu2K8EWFS326PaI3nHLgI/h44JIYb9zhI0PVeZcKscL+KZLldMjo/nvR4 BwtA== 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; bh=Mj/xWhImLzf051Pq2tN2kXqsjTfE6EsHHZj4p3G/stM=; b=rmpXdtduEI1hCzJU2ilbioMbov9M5qzImvJI8/pS6B4OSk5uXUVv2hmQN5uMqSwfnr sI+jfECXyTh3mY/3PS0ioXi+dq8MvDRKoTweSgjRu1ZXOIONPOyN+HRagss20ODwLq6l vinfbx1jLDmDa2Eqnq2sjg+IRxtjC4N6zYQsiLJhquu04sh8Uf0se/wTy4VDKlt+IoaV FYgtwVN2nSko5t41N1yokCk8MvLMH8udAHLL+2jSCNTY99rihbFOPW+I63aiqek36XjC Dg7urKsjOEm8Z7wUtASJilMYlEh0U73QCjEkro4/DCz25FNmK0mHPu/QUtOL0lqlCRlX Lt7Q== X-Gm-Message-State: AOAM53142jUPXVY9K9/uPDu/hwBYaZP28QGnB6Kmv9Z6Tizorx2YJpV4 Z9+vaVrg/VXIKRP2jOCV4o2Tu00gg70NOzHCiOw= X-Google-Smtp-Source: ABdhPJyYrFNeomxsAp33zVUF/Cqh3zb+WuKFGAj3g+Xn3/uu8kkKva8PdqXszGDEEfclI5ilt1Ul0KBUJ60gq2MJjw0= X-Received: by 2002:a9d:4816:: with SMTP id c22mr35049829otf.358.1609261942987; Tue, 29 Dec 2020 09:12:22 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 29 Dec 2020 18:12:12 +0100 Message-ID: To: tyson andre Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary="000000000000765e5805b79d7ecb" Subject: Re: [PHP-DEV] Proposal: Adding SplFixedArray->push() and SplFixedArray->pop() From: benjamin.morel@gmail.com (Benjamin Morel) --000000000000765e5805b79d7ecb Content-Type: text/plain; charset="UTF-8" On Tue, 29 Dec 2020 at 18:04, tyson andre wrote: > Hi Internals, > > Currently, PHP doesn't have a built in memory-efficient array type with > convenient push, pop, and other operations, similar to a list/vector in > other languages. > The closest built in in SPL is [SplFixedArray]( > https://www.php.net/manual/en/class.splfixedarray.php) > > https://www.php.net/manual/en/class.splstack.php uses a doubly linked > list, which uses much more memory and time than sequential memory. > > Contrary to the name and description in > https://www.php.net/manual/en/class.splfixedarray.php, the class is > already resizable. > The resize method is setSize - > https://www.php.net/manual/en/splfixedarray.setsize.php > (increasing size is efficient - erealloc will extend the underlying array > into free memory if there is nothing in the way) > > Many programming languages have a memory-efficient list/vector type that > can be conveniently appended to and popped from. > > https://docs.python.org/3/tutorial/datastructures.html#more-on-lists > https://www.cplusplus.com/reference/vector/vector/ > https://docs.ruby-lang.org/en/2.0.0/Array.html#method-i-push > > Is there any interest in adding this? It would be much more efficient to > add these in C. > > Thanks, > - Tyson > Hi Tyson, Did you have a look at ext-ds? It provides several very efficient data structures: https://github.com/php-ds/ext-ds I would love if this extension could find its way into core, actually. Kind regards, Benjamin --000000000000765e5805b79d7ecb--