Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #73705

Re: print statements and profiling a function slowed performance

References <d5d8cea5-c4c9-42c4-865f-9efe33b162ed@googlegroups.com> <mailman.11265.1403810111.18130.python-list@python.org> <bd29ac07-f93d-4b59-8c5b-78e5ce8b6e4c@googlegroups.com> <CAPTjJmrw4XK8pXfgWCH_GRTJGa3cF+PiC3Hp2qJ2peQnic-d4g@mail.gmail.com> <5bhtq95qm64rtt8vqbne1ms87t793ab958@4ax.com>
Date 2014-06-28 23:50 +1000
Subject Re: print statements and profiling a function slowed performance
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.11308.1403963435.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Sat, Jun 28, 2014 at 11:41 PM, Dennis Lee Bieber
<wlfraed@ix.netcom.com> wrote:
> On Fri, 27 Jun 2014 12:06:54 +1000, Chris Angelico <rosuav@gmail.com>
> declaimed the following:
>
>>
>>If x is, say, range(1000000), a simple "for foo in x: pass" will
>>complete fairly quickly (maybe 100ms on my computer), while the
>>progress-indicated loop will take much longer (about 30 seconds when I
>>tried it). Obviously you'll be doing more work than just "pass", but
>
>         I take it those are subjective feelings of time...

No, they were measured; but the exact difference will depend on Python
version, console, OS, etc, etc, etc, etc, etc, which is why I said
"maybe 100ms" - on one run it was about that (rounded aggressively to
make for convenient figures), but if I ran the test again, it might
come out at 50ms or 200ms. For what it's worth, I did the test on
Python 3.5(ish) on Linux; since you tested it on Python 2, a closer
comparison would be to use xrange rather than range, to avoid the RAM
overhead.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

print statements and profiling a function slowed performance CM <cmpython@gmail.com> - 2014-06-26 11:44 -0700
  Re: print statements and profiling a function slowed performance Michael Torrie <torriem@gmail.com> - 2014-06-26 13:14 -0600
    Re: print statements and profiling a function slowed performance CM <cmpython@gmail.com> - 2014-06-26 13:36 -0700
      Re: print statements and profiling a function slowed performance Chris Angelico <rosuav@gmail.com> - 2014-06-27 12:06 +1000
      Re: print statements and profiling a function slowed performance Michael Torrie <torriem@gmail.com> - 2014-06-26 19:59 -0600
      Re: print statements and profiling a function slowed performance Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-06-28 09:41 -0400
      Re: print statements and profiling a function slowed performance Chris Angelico <rosuav@gmail.com> - 2014-06-28 23:50 +1000
      Re: print statements and profiling a function slowed performance Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-06-29 02:14 -0400
      Re: print statements and profiling a function slowed performance Chris Angelico <rosuav@gmail.com> - 2014-06-29 17:14 +1000
  Re: print statements and profiling a function slowed performance Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-06-26 20:27 +0100
    Re: print statements and profiling a function slowed performance CM <cmpython@gmail.com> - 2014-06-26 13:37 -0700
      Re: print statements and profiling a function slowed performance Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-06-27 02:55 +0000
        Re: print statements and profiling a function slowed performance Chris Angelico <rosuav@gmail.com> - 2014-06-27 13:14 +1000
        Re: print statements and profiling a function slowed performance Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-06-27 16:55 +0100
        Re: print statements and profiling a function slowed performance Skip Montanaro <skip@pobox.com> - 2014-06-27 11:05 -0500
        Re: print statements and profiling a function slowed performance Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-27 15:35 -0600
        Re: print statements and profiling a function slowed performance Skip Montanaro <skip@pobox.com> - 2014-06-27 19:12 -0500
        Re: print statements and profiling a function slowed performance Chris Angelico <rosuav@gmail.com> - 2014-06-28 10:29 +1000
          Re: print statements and profiling a function slowed performance Marko Rauhamaa <marko@pacujo.net> - 2014-06-28 22:20 +0300
            Re: print statements and profiling a function slowed performance Chris Angelico <rosuav@gmail.com> - 2014-06-29 09:30 +1000
            Re: print statements and profiling a function slowed performance Rustom Mody <rustompmody@gmail.com> - 2014-06-28 19:25 -0700
              Re: print statements and profiling a function slowed performance Chris Angelico <rosuav@gmail.com> - 2014-06-29 12:32 +1000
        Re: print statements and profiling a function slowed performance Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-06-28 02:06 +0100
  Re: print statements and profiling a function slowed performance Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-06-26 22:11 -0400

csiph-web