lz4 or snappy | lz4 php,python

http://code.google.com/p/snappy/

http://code.google.com/p/lz4/

snappy wikipedia

http://en.wikipedia.org/wiki/Snappy_(software)

lz4 komiyaさんのslideshare

http://www.slideshare.net/komiyaatsushi/dsirnlp-3-lz4

lz4のほうが速度は速いらしいです。

とりあえずlz4入れてみます。

php と pythonで確認してみます。
php用

https://github.com/kjdev/php-ext-lz4

# git clone https://github.com/kjdev/php-ext-lz4.git .
# phpize
# ./configure
# make
# make install
Installing shared extensions:     /usr/lib64/php/modules/
Installing header files:          /usr/include/php/
# echo “extension=lz4.so” > /etc/php.d/lz4.ini

python用

http://pypi.python.org/pypi/lz4

# python-pip install lz4

Successfully installed lz4
Cleaning up…

□ テスト
pythn 配列をmessagepack して、lz4 compress
php lz4 uncompress して unpack

import lz4
import msgpack

data = [1,2,3]
compressed_data = lz4.compress( msgpack.packb(data) )
f = open(‘./test’,’w’)
f.write( compressed_data )
f.close()

$data = file_get_contents( ‘./test’);
var_dump( msgpack_unserialize( lz4_uncompress( $data ) ) );
array(3) {
 [0]=>
 int(1)
 [1]=>
 int(2)
 [2]=>
 int(3)
}

問題なくデータ受け渡し出来ました。

This entry was posted on 木曜日, 11月 8th, 2012 at 10:45 PM and is filed under php, Python. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Unityによるゲームを公開しております iOS/Android
https://itunes.apple.com/jp/app/lost-knight-3d-action/id900917032
https://play.google.com/store/apps/details?id=com.groundroad.runknight

各種開発支援・機能開発等小さいお仕事などもお請けしております。
unity開発支援, PHPシステム開発, javascript/html5 フロント開発, titanium mobileアプリ開発
お気軽にお問い合わせください
大崎・五反田近郊での対面でのお打ち合わせはいつでも可能です。