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


Groups > comp.lang.python > #85014

Re: Create dictionary based of x items per key from two lists

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!panix!not-for-mail
From Grant Edwards <invalid@invalid.invalid>
Newsgroups comp.lang.python
Subject Re: Create dictionary based of x items per key from two lists
Date Sun, 1 Feb 2015 18:14:53 +0000 (UTC)
Organization PANIX Public Access Internet and UNIX, NYC
Lines 26
Message-ID <malqet$kf0$1@reader1.panix.com> (permalink)
References <0dddee06-233b-436a-be48-3c16e62c1718@googlegroups.com> <CAPTjJmoJmr6PUwGEtpOZ=i2Kff=AMEuuK2kvzuT23fefJg1j8g@mail.gmail.com> <mak57e$3pd$1@ger.gmane.org> <mailman.18347.1422760944.18130.python-list@python.org>
NNTP-Posting-Host 97-91-88-140.dhcp.roch.mn.charter.com
X-Trace reader1.panix.com 1422814493 20960 97.91.88.140 (1 Feb 2015 18:14:53 GMT)
X-Complaints-To abuse@panix.com
NNTP-Posting-Date Sun, 1 Feb 2015 18:14:53 +0000 (UTC)
User-Agent slrn/1.0.1 (Linux)
Xref csiph.com comp.lang.python:85014

Show key headers only | View raw


On 2015-02-01, Chris Angelico <rosuav@gmail.com> wrote:
> On Sun, Feb 1, 2015 at 2:06 PM, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
>> The one-liner might not be better code, but it must be better speed wise
>> precisely because it's on one line, right? :)
>
> Well of course it is. Python code speed is always measured in lines
> per minute. That's why you should eliminate blank lines from your
> code.

No, you've got that backwards.  You want _more_ blank lines. A blank
line takes zero time to run, but it still counts as a line in your
lines/second stats.

A loop containing 1 line of code will execute in the same abount of
time as that loop with 1 line of code and 99 blanks lines.

The latter loop is running at 100 times as many lines/second as the
former.   That's _got_ to be better.

-- 
Grant




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


Thread

Create dictionary based of x items per key from two lists rajanbond@gmail.com - 2015-01-30 18:27 -0800
  Re: Create dictionary based of x items per key from two lists Chris Angelico <rosuav@gmail.com> - 2015-01-31 13:38 +1100
  Re: Create dictionary based of x items per key from two lists Jason Friedman <jsf80238@gmail.com> - 2015-01-31 19:38 -0700
    Re: Create dictionary based of x items per key from two lists rajanbond@gmail.com - 2015-02-02 10:48 -0800
    Re: Create dictionary based of x items per key from two lists rajanbond@gmail.com - 2015-02-02 11:00 -0800
  Re: Create dictionary based of x items per key from two lists Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-02-01 03:06 +0000
  Re: Create dictionary based of x items per key from two lists Chris Angelico <rosuav@gmail.com> - 2015-02-01 14:22 +1100
    Re: Create dictionary based of x items per key from two lists Grant Edwards <invalid@invalid.invalid> - 2015-02-01 18:14 +0000
      Re: Create dictionary based of x items per key from two lists Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-02-01 18:49 +0000
      Re: Create dictionary based of x items per key from two lists mm0fmf <none@mailinator.com> - 2015-02-01 18:52 +0000
      Re: Create dictionary based of x items per key from two lists Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-01 12:36 -0700
        Re: Create dictionary based of x items per key from two lists wxjmfauth@gmail.com - 2015-02-02 23:13 -0800
      Re: Create dictionary based of x items per key from two lists Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-02-01 20:28 +0000
      Re: Create dictionary based of x items per key from two lists Chris Angelico <rosuav@gmail.com> - 2015-02-02 07:33 +1100
  Re: Create dictionary based of x items per key from two lists Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-01 11:51 -0700

csiph-web