Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47407 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42027 invoked from network); 18 Mar 2010 17:22:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Mar 2010 17:22:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Linux 2.6 Received: from [82.113.146.227] ([82.113.146.227:39634] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 93/FF-20429-D5162AB4 for ; Thu, 18 Mar 2010 12:22:38 -0500 Received: from localhost (xdebug.org [127.0.0.1]) by xdebug.org (Postfix) with ESMTPS id 6AD21DE13D; Thu, 18 Mar 2010 17:22:34 +0000 (UTC) Date: Thu, 18 Mar 2010 17:22:34 +0000 (GMT) X-X-Sender: derick@kossu.derickrethans.nl To: Ben DeMott cc: PHP Developers Mailing List In-Reply-To: <99828cd71003180955k48ae834flb8ad2c55b5001692@mail.gmail.com> Message-ID: References: <56.96.20429.EC352AB4@pb1.pair.com> <99828cd71003180955k48ae834flb8ad2c55b5001692@mail.gmail.com> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [PHP-DEV] PHP Variable Storage / DBUS From: derick@php.net (Derick Rethans) On Thu, 18 Mar 2010, Ben DeMott wrote: > So is the data structure thats being serialized remaining in some form > thats reflective of its binary encoding on the system. Or is there > some byte-encoding that goes on to generalize the binary structure? PHP only knows about binary text, and then numbers and floats. Our current serialize format is just text based. > I guess ... Does it find the values in memory of the distinct values, > and then create a serialized set of indexes in a c-compatible > data-type? > or... is this just another form of string serialization, where > variables are represented by strings encoded in ASCII? The current serializer does do the latter. pecl/dbus does... DBUS serialization of course. > If this is a binary serialization two additional questions: > 1.) Does this mean that you can to some accuracy determine the size of > an in-memory variable by counting the sizeof() on the components that > make up the data-structure in C? nope, that won't work as there are strings that are at least two blocks, and arrays and objects are tons. > 2.) Can the PHP sessions serialization be made to use this type of > serialization - so the serialized values could be shared between > multiple applications.. (let me give you an example) Thereis an igbinary extension/serializer. > Would I be better off just re-implementing the PHP C code for its > session serializer/deserializer in Python than attempting to keep it > binary? What you want... both work. > For PHP Sessions, lets say you use memcached to store a serialized > representation of the session. > Lets also say that you would like to read that session data > occasionally by python to offload work that your webserver would > normally have to perform. > > If you were to write a binary serialized form to memory - the C > implementation of the serialization could by very easily ported to > Python as an extension and both could be maintained with ease > (as both PHP and Python are written in C, a Java variant wouldn't be > too hard either using JNI) The problem is that PHP and Python have different dataytpes, and dbus has yet again others. That is always going to be a problem. > I guess this brings up the question of - How hard would it be to > expose the binary object that dbus sends over-the-wire so it could be > written to file instead? You need a tool such as dbus-monitor, but you need to write the deserialization from DBUS into your "fileformat" yet again. > Overall it would be nice if PHP had a functionality similar to Pythons > Pickle -> to expose to the user so they could store binary > representations of objects as they saw fit. > > It seems to me this would be vastly more efficient than an > ascii-encoding and serialization as well. That's no different from what serialization does really. There is http://opensource.dynamoid.com/ for binary serializations. > If my logic is poorly formed because of a lack of understanding please > feel free to educate me! You write too much text :P regards, Derick -- http://derickrethans.nl | http://xdebug.org Like Xdebug? Consider a donation: http://xdebug.org/donate.php twitter: @derickr and @xdebug