Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119727 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 25319 invoked from network); 16 Mar 2023 14:58:11 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Mar 2023 14:58:11 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DF11B1804D7 for ; Thu, 16 Mar 2023 07:58:10 -0700 (PDT) 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS19151 66.111.4.0/24 X-Spam-Virus: No X-Envelope-From: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (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 ; Thu, 16 Mar 2023 07:58:10 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id D2F455C00DC for ; Thu, 16 Mar 2023 10:58:09 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute4.internal (MEProxy); Thu, 16 Mar 2023 10:58:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-type:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1678978689; x= 1679065089; bh=RXKYL+VEFi6gC7ocBlv6RYBnMf1mifRwRP0wFYTMqUA=; b=j nw2bcAZbfcSrXWCU+0Apki38fbWFKkWbeTja22+ec0DAv6oYz80DXF3sXa4v02OQ Mdd4gXgXfGjxyo7jp0Iksa43J2WNA1AEoYojbU9NTk8nvIv6zQfc7zlA3FKJQh31 4o2jWTuUSqTOWLmKpWC5dGtcFv07S38no+Y/Tyyk3g/Xuq9K6AYoQD4OglEMrOIK rRfXnQqN1PLacgFJQ0WKZsZLC1JlrcNpO0mGc0QRihZirs/6JK1VuWpyT1kX6rQD p9S+c50aHlDZYXFIUzulflSkZBVqy5cuIWeh5RFTGRlwjvbAPBzo+2mjfu88QKre KdUEPNsQUFRqSxrhK/G1w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1678978689; x=1679065089; bh=RXKYL+VEFi6gC 7ocBlv6RYBnMf1mifRwRP0wFYTMqUA=; b=aPhDh4S+dObWtNoBjjDLy37XgJxOe aufs2OBa/z6Q860ckkTmdedC6RGaWDKW3pqeYAc6/gUal0I3/StuUKaiBRfcPxYX 036fbPwjQa1NdFfZXU3BrlokpyaTLR6kbEjUdQxqJG0z6F+LARJASDgX87bBjUbr hwH+Ex50YML8QnQ2hAbYOfm6KHVkQMwojIPfirevquAGq7DbwdtQODKocrDeI6QN PpfU+cHl+OoRFLB2tYSSZOCtOyVRHfcVPSTXF5w2t0mY+G2ywMuK/71GNq33aJGl d9nO9B34NO0UWv1fczDmCWPwtsjjn7xa871NlJ7FDLh06rftA3ZslTkzQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdeftddgjedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeeglefgkeduiedvvdetffeujefftdfhjeeiveehgfff keduveektddvledvvdfffeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 8B5F31700089; Thu, 16 Mar 2023 10:58:09 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-221-gec32977366-fm-20230306.001-gec329773 Mime-Version: 1.0 Message-ID: <50cae338-a42b-40ef-9094-77df0015fc20@app.fastmail.com> In-Reply-To: References: Date: Thu, 16 Mar 2023 09:57:49 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] Can we get compile time routines? From: larry@garfieldtech.com ("Larry Garfield") On Thu, Mar 16, 2023, at 9:40 AM, Hans Henrik Bergan wrote: > Something like > ``` > $data = compile_time_routine(function() { > return json_decode(file_get_contents("large.json"), true); > }); > ``` > being equivalent at runtime to > ``` > $data = array(...whatever json_decode returned...); > ``` > and > ``` > echo "opcache compiled at " . compile_time_routine(function(){return > date(DateTime::RFC3339);}); > ``` > being equivalent at runtime to > ``` > echo "opcache compiled at " . "2023-03-16T09:43:00+01:00"; > ``` > > - at my work there are jsons which is being fetched/parsed like > ``` > $data=json_decode(file_get_contents("large.json"), true); > ``` > several times per second, while it would be fine for them to only be > fetched/parsed every time opcache is reset. You can already sort of do this by having a build script that reads the JSON file and then uses var_export() to dump it to a file. You can then just require the file to get the resulting array. Not precisely the same, but gets the same benefit in this case. --Larry Garfield