Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93304 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51768 invoked from network); 13 May 2016 02:51:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 May 2016 02:51:19 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.42 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.220.42 mail-pa0-f42.google.com Received: from [209.85.220.42] ([209.85.220.42:35574] helo=mail-pa0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3B/0C-28272-52145375 for ; Thu, 12 May 2016 22:51:18 -0400 Received: by mail-pa0-f42.google.com with SMTP id iv1so35580734pac.2 for ; Thu, 12 May 2016 19:51:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc; bh=cHwLqwEttoBJ1ZnY5XN0vtMQyPhTysyAUL1T/NNMJ1k=; b=X6GL9Zi0jQyREjS7GG+fSBWCnDND+jYa761FMvhI7dv+k9+8+R8VESBSf93+mgYJml V5IhFr0y9CjNZ+4RzCbANJ5KuQfan6Ksgg0PWIP03cQ7fQiubvBpfPi4E+IaUdpp/1ef +C+dzf9QmVvZVmW1VjY11IuUlVvxTf8kB66h6TqKGLKQ47kQ68drOq7F3Y2tWqvfkOfb aPtfJymlFP7tEYupGbLOHVhM7DzRNXe/0WQiR85ijP28QQXAonk/+1049entvc+yVO8G rOqQ9AJfRgDuhERwWdAOMmAEVE7ohwR5+en4GDFZ7M7+xb234TzfrBiR0zbwqbpJQ3av 9E3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc; bh=cHwLqwEttoBJ1ZnY5XN0vtMQyPhTysyAUL1T/NNMJ1k=; b=ZLCzg+ZvDNfGNGIYK+xUouncHRAxiserS290+YOcucphNKmDwzA/ZGzROZ8SmfeZBR zLiYSBmzP9eF3B8CJWKAyOVCC8hwbxXHpGj460pRJOBGdeVtpckTXxtU/iK6tvqaizIW DkWIMwuVKm9I5E1n8fA7lftABQIUmHm7msPHfnvSJVeMkSH5yLlvN+gfFi1p9j2bmOxP kLsj9ya58IUMFysQ+4pP1oWJNHEvMru0YeGNl5QdIMRylwSS4TNLjI0pJl0PKH1UYf9G H8NOT57H9wzG4l6PJBY0bXaEm7pL1Xwyy+UnMPNtW0OLEiSSuobUoqofVtSVP9tw4m1L okBg== X-Gm-Message-State: AOPr4FUEmBr5g1wHhPMVvqMkGMCRfSNjV2nk34q8krWcxCTAQYhBlA+4IynlQQnySz6aKJv8PapdOb/7wkuSBg== MIME-Version: 1.0 X-Received: by 10.66.132.103 with SMTP id ot7mr19114629pab.27.1463107875461; Thu, 12 May 2016 19:51:15 -0700 (PDT) Sender: morrison.levi@gmail.com Received: by 10.66.132.79 with HTTP; Thu, 12 May 2016 19:51:15 -0700 (PDT) In-Reply-To: References: Date: Thu, 12 May 2016 20:51:15 -0600 X-Google-Sender-Auth: eS5hp0pb3OyXKaypKVzuuCglNHY Message-ID: To: "guilhermeblanco@gmail.com" Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Assess acceptability of having php-ds into core From: levim@php.net (Levi Morrison) On Thu, May 12, 2016 at 7:27 PM, guilhermeblanco@gmail.com wrote: > Hi internals, > > PHP 7 leverages a lot the performance internally and many PHP applications > in the wild. Much of these improvement came by experimentation through > PHPNG and the usage of efficient data structures internally. This idea of > performance improvements are crucial to handle more requests, reduce server > overload, etc. > > However, what lacks in PHP is the exposure of more efficient, use case > specific data structures, that could allow end users to easily improve > performance of their applications, instead of using a general, > multi-purpose data structure that we have as "array". > > Based on that (please keep in mind I haven't spoken with library author), > I'd like assess the receptability of incorporating php-ds library into core. > > Library author wrote a good (and lengthy) article explaining his motivation > and performance benchmarks around it. Here are the related links: > > Article: > https://medium.com/@rtheunissen/efficient-data-structures-for-php-7-9dda7af674cd > Extension: https://github.com/php-ds/extension > Polyfill: https://github.com/php-ds/polyfill > Tests: https://github.com/php-ds/tests > Benchmark: https://github.com/php-ds/benchmarks > > > Best regards, > > -- > Guilherme Blanco > Lead Architect at E-Block I've actually been working on data structures for PHP for years. I'm really glad I haven't pushed for anything before PHP 7, as improvements there give much more control in the data structures which is needed. I can say that work in question is of fairly good quality, though it makes some design decisions that I disagree with. Notably I think the Hashable interface is inferior to asking for hash and equal functions. By forcing the objects to be Hashable or to use spl_object_hash you cannot put objects into Maps or Sets that do not implement the interface (if you need behavior other than spl_object_hash). Routinely this has been a problem of every collection style library I've used before: having to implement a given interface that is new means the majority of the objects you want to put into it do not implement the interface. Also, if we move forward with putting this into core then we need to solidify our namespace. We currently reserve `PHP` and `php` in the docs, but this is not enforced in the runtime. I would not want to put these structures into the global namespace because `Map`, `Set` and `Collection` are all very common names. In any case I encourage people to use the APIs if they are somewhat interested. There is a polyfill available so you can become familiar without installing the extension.