Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123867 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 4D3C21A009C for ; Wed, 26 Jun 2024 12:41:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719405743; bh=GGUl18zzpPLMkoa2V+xpGcSnNl9JjytcCv1KKN93/Vs=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=Yoak1YsB1Or+Mky3aXRemZx1JXN+dIYg6FitlMHWNfC3VFZADV05I818aBDDF+Tk1 JWinlnEVrQ84R4eoKFak0jBaQdcWKTgruWPxfOeleAptazrGkYEeLALLN/9Mgb13am Bm3u0D1hrBAlkJTh7aQdskKL6CRjQtjIkRdfqG4rnXRGaGQ8I/ZVSm+qaUD01e6dYc iZ/siS1VCVv+LLV/FOzEYO2HqK7SDC1N70kWn9D34nU86iIVOZN9bGaiGKnGCR6RLw UyaY20RW6vrwc8B8xep0uzfVejwlltYjYI1LgRVrBUaYDVZebVYJ3Aqi6cxT25fLP+ ZB20Prkz8gUCQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 040CB180A3B for ; Wed, 26 Jun 2024 12:42:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail.sakiot.com (mail.sakiot.com [160.16.227.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 26 Jun 2024 12:42:19 +0000 (UTC) Received: from smtpclient.apple (unknown [117.55.37.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.sakiot.com (Postfix) with ESMTPSA id D8F12401CC; Wed, 26 Jun 2024 21:40:58 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sakiot.com; s=default; t=1719405658; bh=GGUl18zzpPLMkoa2V+xpGcSnNl9JjytcCv1KKN93/Vs=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=TtylBJrWiloHbOnd3/QOYtlQir6B02k/u1AzILRtusZILg/psdKu2AFFZYD1sUNPw MhAj3iwuIaZiBjSwfT00/8xoSH5hB3Dgf2NrR3UXzLU+P09ZEFqt4UErodlagt+OXH fj4DzfKW6jJmF9j7kE1ovv1sp5CHW94jJoeIIXgc= Content-Type: text/plain; charset=utf-8 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: [PHP-DEV] Add bcdivmod() to BCMath In-Reply-To: Date: Wed, 26 Jun 2024 21:40:45 +0900 Cc: Benjamin Morel , Barney Laurance , php internals Content-Transfer-Encoding: quoted-printable Message-ID: References: <190506515d4.f695d014203438.1450648485347018411@barneylaurance.uk> <98CEBD66-4E2C-4CB8-8792-A4AEF9982E41@sakiot.com> To: Marco Pivetta X-Mailer: Apple Mail (2.3774.600.62) From: saki@sakiot.com (Saki Takamachi) Hi Marco, Benjamin, > As for tuple vs reference, I think the general direction is to move = away from references as much as possible, and AFAIK references actually = make things harder for IDEs and static analysis tools, whereas the tuple = syntax array{string, string} is well understood at least by PhpStorm, = Psalm and PHPStan, which can correctly type the function's return value = in their stubs. I see, I agree. This problem seems to be solved by using PHPDoc. > I'm wondering if an array vs an object allocation makes a difference = here, or if the amount of `bcdivmod()` execution dwarfs this sort of = concern? >=20 > Thinking: >=20 > ```php > $result =3D \bcdivmod('123', '2'); >=20 > echo $result->quotient; // '61' > echo $result->remainder; // '1' > ``` >=20 > No idea if that's relevant, so I'm throwing it in the room. BCMath is significantly faster in master, so its cost may have a = significant impact. For reference, here is a speed comparison with 8.3 on my env. The = benchmark used is the code from ext-decimal, which is often introduced = in the context of "BCMath is slow=E2=80=9D. The unit of all measurement = results is "seconds". https://php-decimal.github.io/#performance 8.3 - add int: 3.7771 - add string: 3.0387 - sub int: 3.491 - sub string: 3.0248 - mul int: 5.3318 - mul string: 5.7315 - div int: 10.6659 - div string: 25.762 Master - add int: 1.72 - add string: 1.4444 - sub int: 1.763 - sub string: 1.4745 - mul int: 2.2038 - mul string: 2.0621 - div int: 2.8515 - div string: 2.9411 Regards, Saki=