<commit_before>line_profiler and kernprof
--------------------------

line_profiler is a module for doing line-by-line profiling of functions.
kernprof is a convenient script for running either line_profiler or the Python
standard library's cProfile or profile modules, depending on what is available.

They are available under a `BSD license`_.

.. _BSD license: http://packages.python.org/line_profiler/LICENSE.txt

.. contents::


Installation
============

Source releases and any binaries can be downloaded from the PyPI link.

    http://pypi.python.org/pypi/line_profiler

The current release of the kernprof.py script may be downloaded separately here:

    http://packages.python.org/line_profiler/kernprof.py

To check out the development sources, you can use Mercurial_::

    $ hg clone http://www.enthought.com/~rkern/cgi-bin/hgwebdir.cgi/line_profiler

You may also download source tarballs of any snapshot from that URL.

Source releases will require a C compiler in order to build line_profiler. In
addition, Mercurial checkouts will also require Cython_ >= 0.10. Source releases
on PyPI should contain the pregenerated C sources, so Cython should not be
required in that case.

kernprof.py is a single-file pure Python script and does not require a compiler.
If you wish to use it to run cProfile and not line-by-line profiling, you may
copy it to a directory on your PATH manually and avoid trying to build any
C extensions.

In order to build and install line_profiler, you will simply use the standard
`build and install`_ for most Python packages::

    $ python setup.py install

.. _Mercurial: http://www.selenic.com/mercurial/wiki/
.. _Cython: http://www.cython.org
.. _build and install: http://docs.python.org/install/index.html


line_profiler
=============

The current profiling tools supported in Python 2.5 and later only time
function calls. This is a good first step for locating hotspots in one's program
and is frequently all one needs to do to optimize the program. However,
sometimes the cause of the hotspot is actually a single line in the function,
and that line may not be obvious from just reading the source code. These cases
are particularly frequent in scientific computing. Functions tend to be larger
(sometimes because of legitimate algorithmic complexity, sometimes because the
programmer is still trying to write FORTRAN code), and a single statement
without function calls can trigger lots of computation when using libraries like
numpy. cProfile only times explicit function calls, not special methods called<commit_msg>Change links to github<commit_after>line_profiler and kernprof
--------------------------

line_profiler is a module for doing line-by-line profiling of functions.
kernprof is a convenient script for running either line_profiler or the Python
standard library's cProfile or profile modules, depending on what is available.

They are available under a `BSD license`_.

.. _BSD license: http://github.com/certik/line_profiler/raw/master/LICENSE.txt

.. contents::


Installation
============

Source releases and any binaries can be downloaded from the PyPI link.

    http://pypi.python.org/pypi/line_profiler

The current release of the kernprof.py script may be downloaded separately here:

    http://packages.python.org/line_profiler/kernprof.py

To check out the development sources, you can use Git_::

    $ git clone git://github.com/certik/line_profiler.git

You may also download source tarballs of any snapshot from that URL.

Source releases will require a C compiler in order to build line_profiler. In
addition, Mercurial checkouts will also require Cython_ >= 0.10. Source releases
on PyPI should contain the pregenerated C sources, so Cython should not be
required in that case.

kernprof.py is a single-file pure Python script and does not require a compiler.
If you wish to use it to run cProfile and not line-by-line profiling, you may
copy it to a directory on your PATH manually and avoid trying to build any
C extensions.

In order to build and install line_profiler, you will simply use the standard
`build and install`_ for most Python packages::

    $ python setup.py install

.. _Git: http://git-scm.com/
.. _Cython: http://www.cython.org
.. _build and install: http://docs.python.org/install/index.html


line_profiler
=============

The current profiling tools supported in Python 2.5 and later only time
function calls. This is a good first step for locating hotspots in one's program
and is frequently all one needs to do to optimize the program. However,
sometimes the cause of the hotspot is actually a single line in the function,
and that line may not be obvious from just reading the source code. These cases
are particularly frequent in scientific computing. Functions tend to be larger
(sometimes because of legitimate algorithmic complexity, sometimes because the
programmer is still trying to write FORTRAN code), and a single statement
without function calls can trigger lots of computation when using libraries like
numpy. cProfile only times explicit function calls, not special methods called
{'fraction_non_alphanumeric': 0.06912081456823967, 'fraction_numerical': 0.001958096729978461, 'mean_word_length': 4.1595959595959595, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3971384', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1282, 'n_words': 680}