Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121671 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 537 invoked from network); 14 Nov 2023 12:45:27 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Nov 2023 12:45:27 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E9CCF180504 for ; Tue, 14 Nov 2023 04:45:26 -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,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 14 Nov 2023 04:45:26 -0800 (PST) Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-5a7dd65052aso65665537b3.0 for ; Tue, 14 Nov 2023 04:45:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech.net; s=google; t=1699965925; x=1700570725; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=J3J20t90Ybjm4quPwWjFb4e4N+gLSgXje/2JPymebtI=; b=REYOt8zswii210k5itBwqCvV2BeppUL1B0rwl/CIoZAZGL/NdK/dxw8as7OjYt/Hr4 6svpdolMd9xUVczSfvUq8W16TetUkrjLDeD29RwO57n2H3hdibpWJ+h2BIidH5PD2HhM rn5vLJDPgPFwjcQVINL4Fj4ptlrkMKiPg/FoCEbqrbV+f3s/H3DDBmxoUzmBWpK9WsjA Zjxtuh9ShjlHfNmTexPSmAAowgcR/J8IdMUF6CveQYgpdQ0jtFsVPYCQlLMahNWlO+Hx 36r3s369pCmWT6hhEhuKrnp4ypz16zIEWnWiPh0iEkeRLaWTMgQkqElSB6v5wSzt33qE t0Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699965925; x=1700570725; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J3J20t90Ybjm4quPwWjFb4e4N+gLSgXje/2JPymebtI=; b=iB3RBQE4Loix7sfkJhYpWJzgVXU7KHok/PmpOTW/W8lA8UxKtU4hmrRFDu9v66sg/V 9Xy9BU2IQpZwKtFrdviDKJKQ/un+3jbKx/rnvf/0ctV3Wp4AN819YDx/t3aWZTY6nFKK 01Mof8I2322fAI7vYSIPukHEE2RcGpAtJq6HI+A6phSt+WMlr5VWq5ajVAovi0NvyYZr rtw3q/33UTMcLzlhhfnuFHbGfYajNSU3uwjEMGvwi5P6VqAefHGNm4MbuX3URfBmhp0J MgfqNTyxxCL5O+wVDqlMGLQ80aVwws0sZciJ2Wx8L4aw81deOY/HmQrJmgPmq1sq3Tve tjrg== X-Gm-Message-State: AOJu0YxEy7wNw9do0awgIXxRA94z5ee8L9/myomNDsjudDJbyNlElpuA Xnvo2kVwjouP7XmlpY3VfSavGk1QYiATZiH3P7n8Iw== X-Google-Smtp-Source: AGHT+IEzfO46e8Mzb8Tl93XWxFCataziFXhLVIFGN4W1yoSdvXkZvBfBNzQRWSZBYyB/k6QCdhoqg8eDjH9f70MxlRw= X-Received: by 2002:a81:6f07:0:b0:5a8:25c9:85c8 with SMTP id k7-20020a816f07000000b005a825c985c8mr8673279ywc.52.1699965925715; Tue, 14 Nov 2023 04:45:25 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 14 Nov 2023 13:45:15 +0100 Message-ID: To: David Gebler Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Array functions with strict comparison From: andreas@dqxtech.net (Andreas Hennings) On Tue, 14 Nov 2023 at 02:08, David Gebler wrote: > > On Sun, Nov 12, 2023 at 8:20=E2=80=AFPM Andreas Hennings > wrote: > > > So to me, this alone is an argument to implement this natively. > > The other argument is that it is kind of sad how the current functions > > don't behave as one would expect. > > > I'd expect there to be a larger and proportionately increasing performanc= e > difference between array_diff versus array_udiff with callback or a > userland array_diff_strict function the larger the datasets you feed in. > But I'm not sure how common either the use case of diffing arrays of 25,0= 00 > or 250,000 elements might be, or needing this comparison to be strict > equality. I suspect the use case where both these conditions apply is ver= y > rare. The idea is to use the new functions in general-purpose algorithms without worrying about type coercion or scaling. > > But if you want to create an RFC, please go for it. You could add an extr= a > parameter to these functions after the input arrays, which was a flag for > strict comparison. Whether such a thing with a default value of non-stric= t > (so not BC breaking) would be considered preferable to new global > functions, I'm not sure. I'd probably go with new functions but maybe > someone else will weigh in with their thoughts. The extra parameter does not really work for array_diff() or array_intersect(), because these have variadic parameters. Or at least it would not be "clean". Technically we could just check if the last parameter is an array or not, and if not, we use it as a control flag. But I don't really like it that much, I prefer clean signatures.