Skip to content

Commit 5f092ab

Browse files
authored
Adds subsection on pickle and refers to it when pickle is mentioned (#942)
Co-authored-by: spjuhel <[email protected]>
1 parent 2ba8be9 commit 5f092ab

7 files changed

+32
-11
lines changed

doc/guide/Guide_Py_Performance.ipynb

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@
1212
"\n",
1313
"This guide covers the following recommendations:\n",
1414
"\n",
15-
"⏲️ **Use profiling tools** to find and assess performance bottlenecks. \n",
16-
"🔁 **Replace for-loops** by built-in functions and efficient external implementations. \n",
17-
"📝 **Consider algorithmic performance**, not only implementation performance. \n",
18-
"🧊 **Get familiar with NumPy:** vectorized functions, slicing, masks and broadcasting. \n",
19-
"⚫ **Miscellaneous:** sparse arrays, Numba, parallelization, huge files (xarray), memory. \n",
15+
"⏲️ **Use profiling tools** to find and assess performance bottlenecks.\n",
16+
"🔁 **Replace for-loops** by built-in functions and efficient external implementations.\n",
17+
"📝 **Consider algorithmic performance**, not only implementation performance.\n",
18+
"🧊 **Get familiar with NumPy:** vectorized functions, slicing, masks and broadcasting.\n",
19+
"⚫ **Miscellaneous:** sparse arrays, Numba, parallelization, huge files (xarray), memory, pickle format.\n",
2020
"⚠️ **Don't over-optimize** at the expense of readability and usability."
2121
]
2222
},
2323
{
2424
"cell_type": "markdown",
25+
"id": "33f970c4",
2526
"metadata": {
2627
"slideshow": {
2728
"slide_type": "slide"
@@ -1095,6 +1096,23 @@
10951096
},
10961097
{
10971098
"cell_type": "markdown",
1099+
"id": "0ca35e9e",
1100+
"metadata": {
1101+
"slideshow": {
1102+
"slide_type": "slide"
1103+
}
1104+
},
1105+
"source": [
1106+
"(saving-with-pickle)=\n",
1107+
"### Using pickle to save python objects\n",
1108+
"`pickle` is the standard python library [serialization module](https://docs.python.org/3/library/pickle.html).\n",
1109+
"It has the nice feature of being able to save most of python objects (standard and user defined) using simple methods.\n",
1110+
"However, pickle is *transient*, i.e. it has limited Portability: Pickle files are specific to the Python environment they were created in. This means that Pickle files may not be compatible across different Python versions or environments, which can make it challenging to share data between systems. As such it should only be used for temporary storage and not for persistent one."
1111+
]
1112+
},
1113+
{
1114+
"cell_type": "markdown",
1115+
"id": "de8dca2c",
10981116
"metadata": {
10991117
"slideshow": {
11001118
"slide_type": "slide"

doc/tutorial/1_main_climada.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@
10821082
"\n",
10831083
">**Exercise:** Plot the impacts of Hurricane Maria. To do this you'll need to set `save_mat=True` in the earlier `ImpactCalc.impact()`.\n",
10841084
"\n",
1085-
"We can save our variables in pickle format using the `save` function and load them with `load`. This will save your results in the folder specified in the configuration file. The default folder is a `results` folder which is created in the current path (see default configuration file `climada/conf/defaults.conf`). However, we recommend to use CLIMADA's writers in `hdf5` or `csv` whenever possible."
1085+
"We recommend to use CLIMADA's writers in `hdf5` or `csv` whenever possible. It is also possible to save our variables in pickle format using the `save` function and load them with `load`. This will save your results in the folder specified in the configuration file. The default folder is a `results` folder which is created in the current path (see default configuration file `climada/conf/defaults.conf`). The pickle format has a [transient format](saving-with-pickle) and should be avoided when possible."
10861086
]
10871087
},
10881088
{

doc/tutorial/climada_entity_DiscRates.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,10 @@
179179
},
180180
{
181181
"cell_type": "markdown",
182+
"id": "37bf8fe8",
182183
"metadata": {},
183184
"source": [
184-
"Pickle can always be used as well:"
185+
"Pickle can always be used as well, but note that pickle has a [transient format](saving-with-pickle) and should be avoided when possible:"
185186
]
186187
},
187188
{

doc/tutorial/climada_entity_Exposures.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1757,9 +1757,10 @@
17571757
},
17581758
{
17591759
"cell_type": "markdown",
1760+
"id": "5d078d09",
17601761
"metadata": {},
17611762
"source": [
1762-
"Finallly, as with any Python object, use climada's save option to save it in pickle format."
1763+
"Finally, as with any Python object, use climada's save option to save it in pickle format. Note however, that pickle has a transient format and should be avoided when possible."
17631764
]
17641765
},
17651766
{

doc/tutorial/climada_entity_ImpactFuncSet.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@
492492
"source": [
493493
"#### Alternative saving format\n",
494494
"\n",
495-
"Alternatively, users may also save the impact functions into [pickle format](https://docs.python.org/3/library/pickle.html), using CLIMADA in-built function `save()`."
495+
"Alternatively, users may also save the impact functions into [pickle format](https://docs.python.org/3/library/pickle.html), using CLIMADA in-built function `save()`. Note that pickle has a [transient format](saving-with-pickle) and should be avoided when possible."
496496
]
497497
},
498498
{

doc/tutorial/climada_entity_MeasureSet.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,9 +620,10 @@
620620
},
621621
{
622622
"cell_type": "markdown",
623+
"id": "adb8d606",
623624
"metadata": {},
624625
"source": [
625-
"Pickle can always be used as well:"
626+
"Pickle can be used as well, but note that pickle has a [transient format](saving-with-pickle) and should be avoided when possible:"
626627
]
627628
},
628629
{

doc/tutorial/climada_hazard_Hazard.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@
864864
"cell_type": "markdown",
865865
"metadata": {},
866866
"source": [
867-
"Pickle will work as well:"
867+
"Pickle will work as well, but note that pickle has a [transient format](saving-with-pickle) and should be avoided when possible:"
868868
]
869869
},
870870
{

0 commit comments

Comments
 (0)