README.rst 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. python-snappy
  2. =============
  3. Python library for the snappy compression library from Google.
  4. This library is distributed under the New BSD License
  5. (http://www.opensource.org/licenses/bsd-license.php).
  6. Dependencies
  7. ============
  8. * snappy library >= 1.0.2 (or revision 27)
  9. http://code.google.com/p/snappy/
  10. * Supports Python 2.7 and Python 3
  11. Build & Install
  12. ===============
  13. Build:
  14. ::
  15. python setup.py build
  16. Install:
  17. ::
  18. python setup.py install
  19. Or install it from PyPi:
  20. ::
  21. pip install python-snappy
  22. Run tests
  23. =========
  24. ::
  25. nosetest test_snappy.py
  26. Benchmarks
  27. ==========
  28. *snappy vs. zlib*
  29. **Compressing:**
  30. ::
  31. %timeit zlib.compress("hola mundo cruel!")
  32. 100000 loops, best of 3: 9.64 us per loop
  33. %timeit snappy.compress("hola mundo cruel!")
  34. 1000000 loops, best of 3: 849 ns per loop
  35. **Snappy** is **11 times faster** than zlib when compressing
  36. **Uncompressing:**
  37. ::
  38. r = snappy.compress("hola mundo cruel!")
  39. %timeit snappy.uncompress(r)
  40. 1000000 loops, best of 3: 755 ns per loop
  41. r = zlib.compress("hola mundo cruel!")
  42. %timeit zlib.decompress(r)
  43. 1000000 loops, best of 3: 1.11 us per loop
  44. **Snappy** is **twice** as fast as zlib
  45. Commandline usage
  46. =================
  47. You can invoke Python Snappy to compress or decompress files or streams from
  48. the commandline after installation as follows
  49. Compressing and decompressing a file:
  50. ::
  51. $ python -m snappy -c uncompressed_file compressed_file.snappy
  52. $ python -m snappy -d compressed_file.snappy uncompressed_file
  53. Compressing and decompressing a stream:
  54. ::
  55. $ cat uncompressed_data | python -m snappy -c > compressed_data.snappy
  56. $ cat compressed_data.snappy | python -m snappy -d > uncompressed_data
  57. You can get help by running
  58. ::
  59. $ python -m snappy --help
  60. Snappy - compression library from Google (c)
  61. http://code.google.com/p/snappy