Skip to content

Instantly share code, notes, and snippets.

@kain88-de
Created August 27, 2016 12:11
Show Gist options
  • Save kain88-de/a453ae0c58a38bd343a88c863d7b6840 to your computer and use it in GitHub Desktop.
Save kain88-de/a453ae0c58a38bd343a88c863d7b6840 to your computer and use it in GitHub Desktop.
filesize comparison
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import numpy as np\n",
"import cPickle as pickle\n",
"import yaml"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"test_data = {}\n",
"for i in range(10):\n",
" test_data[i] = np.random.normal(size=(1000, 3, 3))"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"with open('test.pkl', 'w') as f:\n",
" pickle.dump(test_data, f)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"with open('test-high.pkl', 'w') as f:\n",
" pickle.dump(test_data, f, protocol=pickle.HIGHEST_PROTOCOL)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/max/conda/lib/python2.7/site-packages/yaml/representer.py:142: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.\n",
" if data in [None, ()]:\n"
]
}
],
"source": [
"with open('test.yaml', 'w') as f:\n",
" yaml.dump(test_data, f)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"total 3.8M\r\n",
"-rw-rw-r--. 1 max max 704K Aug 27 14:08 test-high.pkl\r\n",
"-rw-rw-r--. 1 max max 2.1M Aug 27 14:07 test.pkl\r\n",
"-rw-rw-r--. 1 max max 1003K Aug 27 14:08 test.yaml\r\n",
"-rw-rw-r--. 1 max max 1.1K Aug 27 14:07 Untitled.ipynb\r\n"
]
}
],
"source": [
"!ls -lh"
]
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python [default]",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment