{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Pickling\n\nThis example pickles a function.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "from math import sqrt\nimport pickle\n\nfrom joblib import Parallel, delayed\n\nassert __name__ == '__main__'\nassert '__file__' not in globals()\n\n\ndef function(x):\n    return sqrt(x)\n\n\npickle.loads(pickle.dumps(function))\n\n# Now with joblib\nprint(Parallel(n_jobs=2)(delayed(sqrt)(i ** 2) for i in range(10)))\nprint(Parallel(n_jobs=2)(delayed(function)(i ** 2) for i in range(10)))"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.7.5"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}