Giter Site home page Giter Site logo

pombredanne / ipycache Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rossant/ipycache

0.0 2.0 0.0 492 KB

Defines a %%cache cell magic in the IPython notebook to cache results of long-lasting computations in a persistent pickle file

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

ipycache's Introduction

%%cache cell magic

Build Status

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.

  • Alternatively use $file_name instead of mycache.pkl, where file_name is a variable holding the path to the file used for caching.

  • 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 ~\.ipython\profile_default\ipython_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.

ipycache's People

Contributors

rossant avatar ihrke avatar ckald avatar mpelko avatar bitdeli-chef avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.