Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122336 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 6454 invoked from network); 7 Feb 2024 22:09:22 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Feb 2024 22:09:22 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1707343815; bh=kCAW4qOtvdvImJSGgtmCFaJb/y+H9bSOP2C2H8zVqAo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=JKiEKUI8a/Ba73i5PLc/SPjFT3XS6vqqRN+TS4kCtL0solXbxQEHKZeQAtvYAdgra c77pezbJT8MdvdcRF18u6UXZZyiODlXjM8r5uQk+SBlf8C1aIX446kCZ7Xak8FmFjm S76laCuKdFePAfsvrH0Q2SW02C/ITGe59soM1M+NwXSGz/+boJxfth+mHoaCP3KV+3 KAW/Mr33H+HK/slLA8V2y8xcT5nJlZXlJih+nTIKtNwZvHQv5CY+1GRfkMxmzyySI4 wjdYnghNfb/Uboje4bvBgi6BrSUhcKt8uUTGF0lBr297qZGP3cMda87m7d6lKA9Dfq Ckr1j9MZG4oKQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 81813180039 for ; Wed, 7 Feb 2024 14:10:13 -0800 (PST) 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.3 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, URIBL_SBL_A autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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, 7 Feb 2024 14:10:13 -0800 (PST) Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-3394ca0c874so877885f8f.2 for ; Wed, 07 Feb 2024 14:09:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707343758; x=1707948558; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=kCAW4qOtvdvImJSGgtmCFaJb/y+H9bSOP2C2H8zVqAo=; b=FChcuo6EeS/WagdViu38Zxl9g+39vcP56OKUV6k69o03dwPWmp8uMcPpi/s2G2zNuH Vp/EV8nn1CpWjIy1152I8onRBStj3z55c9dvplu94naqC3M27laUWO2gYc4T86WEZ8fi U55T93t3vRU4bGXkswLalWW1NJ5gL/OYzmpkjXinie8qUYPYzQ0+J4ER4gpqDc94HU9D uw6beUA/um0cIC6cH0vxSSSzk74XQUYA9q81/nOanxOY4m0yirlRj01RkqVvYrW7kYjY z8O9zSLW3DhgMipDhWPePJYPmINvpRb7cUhC2uKlKU9DJsso3x0kiEQUp2/YrnP7LLej gmRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707343758; x=1707948558; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kCAW4qOtvdvImJSGgtmCFaJb/y+H9bSOP2C2H8zVqAo=; b=BfP8hd9eRGpo5pZINvcn5tlGCTjNHU/soj84GMIDZTvZt58HhZsBLyO3WDKrpFvjfA t5vHyUMVN2bT9jXdm44zHDVF5OqtW0+TmbLB1Kh+mNgFEl4jDD5AgsssDa47Yncz7jCh QKoY4BoPeQCQEifFbRpUyLKTm3spf+JCUyPKHyRxAstrw5dzzh43QrHfNdNlXcnb+Gyg ymYbtGlAv9su9QoFg/iDDjMlfbVnQUepTTX3KcKjzIjsB0D+BTneEnMeKXrjx9HZob0n tUMkS6+NfAyj1hkLHRVpnTkMMRp0DWeFzEHdCh7C6YBCcOc/j0wzi30LvERTx/qTCPYQ +vbg== X-Gm-Message-State: AOJu0YyY+d4PpCvMbb7M25AvQ1eHirMivWHx0ek1B45CrH4QXD+8xbAI PyZa5FC7M8Y0AzOhM3sRl+cA33M5iVcVc8MMDRejlLvvxwVc4mvZ/eeQ6X+hmxg6KJMvH6SB2pm Odt9BR5hvvRw3QFeSTk75ACbSK5k+dvcFriU= X-Google-Smtp-Source: AGHT+IF+ff7gdH9fATinlnD6qOqG46QUFC6pngZIGd5Lt+WYlkwf8dOf0FM3JC4RaHH3NXIHlYKHuYX0tR7h1N/Z+Zo= X-Received: by 2002:adf:edc9:0:b0:33b:2516:727d with SMTP id v9-20020adfedc9000000b0033b2516727dmr4006462wro.35.1707343758320; Wed, 07 Feb 2024 14:09:18 -0800 (PST) MIME-Version: 1.0 References: <2597df91-56c5-4e53-82c3-26a1ac6bb38b@app.fastmail.com> In-Reply-To: <2597df91-56c5-4e53-82c3-26a1ac6bb38b@app.fastmail.com> Date: Wed, 7 Feb 2024 17:09:06 -0500 Message-ID: To: Jim Winstead Cc: PHP Internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Why are serialized strings wrapped in double quotes? (s::"") From: figureonecpr@gmail.com (Sanford Whiteman) Nice work, Jim. >I enjoy spelunking in the history of the project, so I did some digging. I= t >looks to me like Kris didn't quite get the history correct. Boris did prop= ose >a form of serialization first, but it looks like what became serialize() a= nd >unserialize() came into the project another way. > >https://marc.info/?l=3Dphp-general&m=3D90222513234434&w=3D2 > >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=C3=A4ki: > >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, alth= ough 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 approache= s without being officially discussed. In the grand scheme even if you're wast= ing 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 tak= e Sergey's results it's way faster than JSON, at least when it's PHP doing th= e unserialization: https://grechin.org/2021/04/06/php-json-encode-vs-serialize-performance-com= parison.html =E2=80=94 S.