HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
rkern
line_profiler
Python2015–2020
rkern / line_profiler · Archived

line_profiler

(OLD REPO) Line-by-line profiling for Python - Current repo ->

6Distinct people
6Mentions
0Explicit recommenders
3.6KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

(OLD REPO) Line-by-line profiling for Python - Current repo ->

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 3:56:07 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year6 dated mentions

Observed mentions: 2015-07-28 19:39:43 UTC to 2020-01-01 20:56:23 UTC.

01232015-01-01 00:00:00 UTC to 2016-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20152016-01-01 00:00:00 UTC to 2017-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 3 mentions; 1 submissions, 2 comments20172018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2020

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20152015-01-01 00:00:00 UTC2016-01-01 00:00:00 UTC101
20162016-01-01 00:00:00 UTC2017-01-01 00:00:00 UTC101
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC312
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC000
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC000
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC101

What Hacker News says

6 sources
Should also use kernprof - https://github.com/rkern/line_profiler - to see which lines in that function take the most time. Oddly, none of the techniques listed would help that slow_program.py function since kernprof says that 99.8% of the time is spent in: s += num / fact One comment about "# Fast:" / "from re import findall" -- That's not fast. Sure, it reduces a getattr lookup, but it's much better to pre-compile the regex than to pass it in to re.findall() each time. Now, re.findall() does cache the last 100 or so regexps, so it probably won't re-evaluate the regex each time. But really, pre-compute that regex with "_my_pattern = re.compile(regex) ... _my_pattern.findall()" and avoid even that cache lookup.
In Making Python Programs Blazingly Fast
> We changed timeit to now report average +/- standard deviation, which is better than the misleading minimum value reported in CPython. While I don't agree with many of the CPython devs ideas/decisions/crawling-pace-decision-making, I don't like the tone with which PyPy devs refer to them most of the time. It's like a rivalry which is ignored from the CPython side, even unacknowledged. And PyPy is not the Holy Grail of Python, it's just another implementation which runs into its own problems on some places[0], so it feels weird seeing them with kind of constant badgering of "the other guys". The feature looks interesting, still if you don't like a particular feature/profiler/timer for Python, there's nothing stoping you from making your own[1], like kernprof which is amazing. [0] for example, if you don't follow RPythons "way of doing th
Read the rest
ings" you can end up with even slower performance than CPython -- I know because I've done it! [1] https://github.com/rkern/line_profiler#id7
In PyPy2.7 v5.6 released – stdlib 2.7.12 support, C-API improvements, and more
I'm a fan of line_profiler: https://github.com/rkern/line_profiler % cat > l.py @profile def slow_func(): for i in xrange(1048576): continue return -1 @profile def fast_func(): for i in xrange(10): continue return -1 @profile def the_func(): for i in xrange(10): slow_func() fast_func() if __name__ == "__main__": the_func() % kernprof -l l.py % python -m line_profiler l.py.lprof Timer unit: 1e-06 s Total time: 5.21814 s File: l.py Function: slow_func at line 1 Line # Hits
Read the rest
Time Per Hit % Time Line Contents ============================================================== 1 @profile 2 def slow_func(): 3 10485770 2644263 0.3 50.7 for i in xrange(1048576): 4 10485760 2573875 0.2 49.3 continue 5 6 10 5 0.5 0.0 return -1 Total time: 8.9e-05 s File: l.py Function: fast_func at line 8 Line # Hits Time Per Hit % Time Line Contents ============================================================== 8 @profile 9 def fast_func(): 10 110 61 0.6 68.5 for i in xrange(10): 11 100 26 0.3 29.2 continue 12 13 10 2 0.2 2.2 return -1 Total time: 10.5501 s File: l.py Function: the_func at line 14 Line # Hits Time Per Hit % Time Line Contents ============================================================== 14 @profile 15 def the_func(): 16 11 3 0.3 0.0 for i in xrange(10): 17 10 10549853 1054985.3 100.0 slow_func() 18 10 203 20.3 0.0 fast_func()
In Profiling in Python

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.