
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/plot_pickle.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        Click :ref:`here <sphx_glr_download_auto_examples_plot_pickle.py>`
        to download the full example code or to run this example in your browser via Binder

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_plot_pickle.py:


Pickling
--------

This example pickles a function.

.. GENERATED FROM PYTHON SOURCE LINES 7-25




.. rst-class:: sphx-glr-script-out

 Out:

 .. code-block:: none

    [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]
    [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]






|

.. code-block:: python3

    from math import sqrt
    import pickle

    from joblib import Parallel, delayed

    assert __name__ == '__main__'
    assert '__file__' not in globals()


    def function(x):
        return sqrt(x)


    pickle.loads(pickle.dumps(function))

    # Now with joblib
    print(Parallel(n_jobs=2)(delayed(sqrt)(i ** 2) for i in range(10)))
    print(Parallel(n_jobs=2)(delayed(function)(i ** 2) for i in range(10)))


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** ( 0 minutes  0.290 seconds)


.. _sphx_glr_download_auto_examples_plot_pickle.py:


.. only :: html

 .. container:: sphx-glr-footer
    :class: sphx-glr-footer-example


  .. container:: binder-badge

    .. image:: images/binder_badge_logo.svg
      :target: https://mybinder.org/v2/gh/sphinx-gallery/sphinx-gallery.github.io/master?urlpath=lab/tree/notebooks/auto_examples/plot_pickle.ipynb
      :alt: Launch binder
      :width: 150 px


  .. container:: sphx-glr-download sphx-glr-download-python

     :download:`Download Python source code: plot_pickle.py <plot_pickle.py>`



  .. container:: sphx-glr-download sphx-glr-download-jupyter

     :download:`Download Jupyter notebook: plot_pickle.ipynb <plot_pickle.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
