Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115971 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 15687 invoked from network); 6 Sep 2021 16:46:38 -0000 Received: from unknown (HELO localhost.localdomain) (76.75.200.58) by pb1.pair.com with SMTP; 6 Sep 2021 16:46:38 -0000 To: internals@lists.php.net References: <61339ad1.1c69fb81.b518e.8644SMTPIN_ADDED_MISSING@mx.google.com> <61350112.1c69fb81.82294.dff2SMTPIN_ADDED_MISSING@mx.google.com> Autocrypt: addr=ramsey@php.net; keydata= mQINBGCHQTYBEAC6IU9aXEpVuLJNAzXwL7q9Vt1PkxJHr7kJynUg/3ISrOdJy2Ebola7GbEd vLZ69o+NbsL5vmOmT2AD0pEGfMgE9KWJ122iEfN4hrWThz+sHcVd/TKX9E98g+HTpoJGtYcp 6jYxG0YRP7dn1zSn9CawVJpMsoS2G0JZB/q2lIELoPRLMjicRDBEfamTPi3vyYiuf4vvCcYY z3AEMYirt5f7rBrVOs3FVBozEqrN2fPRWvFgTnhsQ8MEiq5/DMsnxFq2wgheAKPIAXhZiJFo KHsrpiAANEmGZBY2pbW05rBY1ZmJpi1yCrSk582cdPo2Ca+NrNEPJ9spoEinAtApp/orirJY bjKViWqmh7mYYyv/NAQKwGBE1up3tSGVj0rKG3f9seLvYsApHf0lhEQN/ypzC+pYDlSXzWxc Q8bifixb6XulaEgB5XOHwuvpTK6HoNNdZM44Fl+B/eAXaebL6Vh0P1EN/2DBr4FGNb8vlXdv Gxs7rJbJ8+aNmYeNIdg5qbYubNsO2fU7yw9kTDNTej63Ql1a0Md2wfZze8dZy6LJ/tL//IH3 JPd0jvT1y0LVIKoYVrIfv06zolVplqi72zfec1kpw0VR6dT/LyhBlyNumqJMRHdZlX4pUCpx 79pOonjHNTNuhjOPLlzai0ooWBtloDZfNGoFRVNNJv/hGvVM+wARAQABtBtCZW4gUmFtc2V5 IDxyYW1zZXlAcGhwLm5ldD6JAlQEEwEIAD4WIQQ5tkE0PYwQSys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QywdD4ivwsgeFcWB3u/RlOcpDfq/EkdXmrzZ3Y VBaPeCN0EPvffcdA7zoUueFI+JConWbme9Mg3oe++tcDvMKlr0HUGVFVCwkF Date: Mon, 6 Sep 2021 12:23:53 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:52.0) Gecko/20100101 PostboxApp/7.0.48 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rei2etLGaRzbxRqrDpgWQlXP9FUGzCt2c" X-Posted-By: 96.61.105.82 Subject: Re: [PHP-DEV] Re: [RFC] Random Extension 3.0 From: ramsey@php.net (Ben Ramsey) Message-ID: --rei2etLGaRzbxRqrDpgWQlXP9FUGzCt2c Content-Type: multipart/mixed; boundary="WGVspw9A2UPWxghNj3kOviDQRQbw3HpNE" --WGVspw9A2UPWxghNj3kOviDQRQbw3HpNE Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Nikita Popov wrote on 9/6/21 03:06: > On Sun, Sep 5, 2021 at 7:40 PM Ben Ramsey wrote: >=20 >> Go Kudo wrote on 9/4/21 23:00: >>> Indeed, it may be true that these suggestions should not be made all = at >>> once. If necessary, I would like to propose to organize the RNG >>> implementation first. >>> >>> Do we still need an RFC in this case? I'm not sure I'm not fully >> understand >>> the criteria for an RFC. Does this internal API change count as a BC >> Break >>> that requires an RFC? >> >> Yes, since re-organizing the RNG implementation is a major language >> change that affects extensions and other downstream projects, this >> requires an RFC. >> >>>> Personally, I don't see the benefit of including this OOP API in the= >> core. >>> >>> On the other hand, can you tell me why you thought it was unnecessary= ? >>> Was my example unrealistic? >> >> You also said, in reply to Dan Ackroyd: >> >>> Either way, I'll try to separate these suggestions if necessary, but = if >> we >>> were to try to provide an OOP API without BC Break, what do you think= >> would >>> be the ideal form? >> >> The OOP API appears to be a wrapper around the RNG functions. The only= >> thing it gains by being in the core is widespread use, but it loses a >> lot of flexibility and maintainability, since the API will be tied to >> PHP release cycles. >> >> By doing this as an OOP wrapper in userland code, you're not restricti= ng >> yourself to release only when PHP releases, and you can work with the >> community (e.g., the PHP-FIG) to develop interfaces that other project= s >> might use so they can make use of their own RNGs, etc. >> >=20 > The OO API is not just a wrapper around the RNG functions -- it provide= s > new functionality that cannot be efficiently implemented in userland co= de. > This is for two reasons: >=20 > 1. It provides independent randomness streams, which means it's not > possible to reuse existing functionality like mt_rand() for this purpos= e, > which only provides a single global random number stream. You would hav= e to > reimplement the random number generator in userland. While this is > possible, it will generally not be efficient, because PHP does not have= > native support for unsigned modular arithmetic, which is what random nu= mber > generators generally need. >=20 > 2. It allows using functions like shuffle() and array_rand() with an > independent randomness stream. These functions cannot be efficiently > implemented in userland, because userland does not have random access t= o > arrays. Internals can generate a random number and use it to pick the k= ey > at that position, which is O(1). Userland would have to call array_keys= () > first to allow random access on keys, which is O(n). >=20 > Which is why I think this is a good addition to php-src. There's three = good > reasons to include functionality in php-src (performance, ubiquity and = FFI) > and this falls squarely into the first category. And now that we have > fibers and need to worry more about multiple independent execution stre= ams, > we also need to worry about multiple independent randomness streams. >=20 > Regards, > Nikita >=20 Thanks for the clarification, Nikita. The RFC says, "The Random class is a utility class that provides functionality using random numbers." This led me to think it was a wrapper that did not introduce new functionality. I can't find any discussion in the RFC on the independent randomness streams provided by the OOP API. Go Kudo, can you update the RFC with more information about this functionality? Cheers, Ben --WGVspw9A2UPWxghNj3kOviDQRQbw3HpNE-- --rei2etLGaRzbxRqrDpgWQlXP9FUGzCt2c Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEObZBND2MEEsrFG3D+cOdwLlphUQFAmE2TqkACgkQ+cOdwLlp hUQDww//TYVRpv2jHH1efy7YdkkxDmg1Wz/I7k3lNGuuxWh621hmowjn2OTnw4w4 sa26pPtOraWvjWaCKkkDhtXWPGueYrHKWU02pXP5MXnzMnp+YIUtRF3S2iV7h5gG OKtV7JZyGbNx7U7oAUptkWoOaBcBoJJ7H5EyyS5GU4zvOdSzVozB8vq/8/QWlXx0 qfd30GP/6cW+0GA/mRE2A9q9l9QVuyjMu2wN8ZeZOZ5F62UPlLuXVwxlhU7ABMB8 vE3q3GvfB9B5V6ujl4qVSY7t9DH7uYCgqN16Ru4ZxbZ2SiMsBjoOc70xboxJZntU RX1L2fcac1nMcXeLA8cSgW8diefvEXozx+zmA+3my5FAZY3puz1k+dZ5sCcPAawo o1CPAeek3rsh/0mJXX+jnES2UGw3hbqzALYd5iyqvczuoCrjJpuOwuj9X46TkKTX Ee4PE1lgdKjQ6clp8VdUS0EZBevIHMjKX42/B62ChexdOeDd8H/bX5olD0IziZ8o MX99JHzImE2U7DDfgU1uhcTIACMESXijQcCeyxGkBN2O8ZwqbApQ8+DqzS9rsn5X +DoQFuIUK6lEQ12UWUrMZkKMnjp9Bd2FTvMytpVe2sy+H78FJkr0Romb+DTDEoid /zLmZDW3aviN62GUb3ryL6X7dOTu/zOVytLeqgHYOAc0Kw15yXM= =5GXO -----END PGP SIGNATURE----- --rei2etLGaRzbxRqrDpgWQlXP9FUGzCt2c--