Skip to content

Can we get compile time routines? #10864

@divinity76

Description

@divinity76

Description

I have a large multi-megabyte JSON that is currently parsed several times per second, I also have OPCache enabled, would save time if the parsing could be done at compile-time rather than runtime, would be nice if i could do something like

$data = compile_time_routine(function() {
    return json_decode(file_get_contents("large.json"), true);
});

instead of

$data = json_decode(file_get_contents("large.json"), true);

with it being equivalent at runtime to

$data = array(...whatever json_decode returned...);

another example would be

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";

(i did not give the function name/argument/details much thought fwiw)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions