Skip to main content

Defines a %%cache cell magic in the IPython notebook to cache results and outputs of long-lasting computations in a persistent pickle file. Useful when some computations in a notebook are long and you want to easily save the results in a file.

Example

Installation

  • pip install ipycache

Usage

  • In IPython:

    %load_ext ipycache

  • Then, create a cell with:

    %%cache mycache.pkl var1 var2 var1 = 1 var2 = 2

  • When you execute this cell the first time, the code is executed, and the variables var1 and var2 are saved in mycache.pkl in the current directory along with the outputs. Rich display outputs are only saved if you use the development version of IPython. When you execute this cell again, the code is skipped, the variables are loaded from the file and injected into the namespace, and the outputs are restored in the notebook.

  • Use the –force or -f option to force the cell’s execution and overwrite the file.

  • Use the –read or -r option to prevent the cell’s execution and always load the variables from the cache. An exception is raised if the file does not exist.

  • Use the –cachedir or -d option to specify the cache directory. You can specify a default directory in the IPython configuration file in your profile (typically in ~.ipythonprofile_defaultipython_config.py) by adding the following line:

    c.CacheMagics.cachedir = “/path/to/mycache”

    If both a default cache directory and the –cachedir option are given, the latter is used.

Metadata

Release files for ipycache 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ipycache 0.1.4
File Size Uploaded
ipycache-0.1.4.zip 7.9 kB Details

Release files / ipycache-0.1.4.zip

Download URL ipycache-0.1.4.zip
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b6deb4281b3709a65959318017705b9639758c5b1bc4bfe985f229f637fdb8ef
BLAKE2b-256 checksum
How to use checksums
922b0370a02e514631e97fc02cedb1c29a6876f820e8ec3ec44eebe46f7c8952
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.4 This release

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page