Nice work, Jim.

>I enjoy spelunking in the history of the project, so I did some digging. It
>looks to me like Kris didn't quite get the history correct. Boris did propose
>a form of serialization first, but it looks like what became serialize() and
>unserialize() came into the project another way.
>
>https://marc.info/?l=php-general&m=90222513234434&w=2
>
>The serialize() and unserialize() functions were first added in PHP 3.0.5
>with that same encoding for strings that you're asking about. Here is the
>original proposal for adding the functions from Jani Lehtimäki:
>
>https://news-web.php.net/php.dev/1444
>
>The were originally conceived as var_save() and var_load() and operated on
>files, but you can see the file format uses the same string encoding, although 
>it used single quotes.
>
>It was committed to CVS by Stig here, but unfortunately the emails to the list 
>didn't include newly-added files.
>
>https://news-web.php.net/php.dev/1540

Huh. So the quotes may have just stuck around from eval()-related approaches
without being officially discussed. In the grand scheme even if you're wasting 2
bytes for every string that could be a tiny % on average.

The format's fascinating because it unmistakably *works*, and binary
igbinary/msgpack aside, it's a pretty good byte-stream encoding. If you take
Sergey's results it's way faster than JSON, at least when it's PHP doing the
unserialization:
https://grechin.org/2021/04/06/php-json-encode-vs-serialize-performance-comparison.html

— S.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to