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


Groups > comp.lang.python > #87685

Re: Brilliant or insane code?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!lightspeed.eweka.nl!lightspeed.eweka.nl!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.013
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'subject:code': 0.07; 'lawrence': 0.09; 'len(x)': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.12; 'thread': 0.14; '[none]': 0.16; 'inverse': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'wrote:': 0.18; 'later': 0.20; 'separate': 0.22; 'header:User-Agent:1': 0.23; "i've": 0.25; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'url:bugs': 0.29; "i'm": 0.30; 'assert': 0.31; 'lists': 0.32; 'url:python': 0.33; 'ago': 0.33; 'problem': 0.35; 'equal': 0.35; 'there': 0.35; 'whilst': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'same.': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'opinions': 0.70; 'received:109': 0.72; 'winner': 0.74; 'special': 0.74; 'otten': 0.84; 'url:lang': 0.84; 'url:posts': 0.84; 'sitting': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Robin Becker <robin@reportlab.com>
Subject Re: Brilliant or insane code?
Date Wed, 18 Mar 2015 15:28:00 +0000
References <meah8u$odg$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 109.174.168.73
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0
In-Reply-To <meah8u$odg$1@ger.gmane.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.19
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5.1426692496.10327.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1426692496 news.xs4all.nl 2832 [2001:888:2000:d::a6]:49159
X-Complaints-To abuse@xs4all.nl
X-Received-Bytes 3523
X-Received-Body-CRC 1226838023
Xref csiph.com comp.lang.python:87685

Show key headers only | View raw


On 18/03/2015 00:35, Mark Lawrence wrote:
> I've just come across this http://www.stavros.io/posts/brilliant-or-insane-code/
> as a result of this http://bugs.python.org/issue23695
>
> Any and all opinions welcomed, I'm chickening out and sitting firmly on the fence.
>

There was a long thread on an inverse problem (2d only interleave separate lists 
of x & y coordinates) in clp some while ago

https://groups.google.com/forum/#!topic/comp.lang.python/ODqrLDRn61k

the winner at that time was was Peter Otten with

> def flatten7(x,y):
> 	 '''Peter Otten special case equal lengths'''
> 	 n = len(x)
> 	 assert len(y) == n
> 	 result = [None] * (2*n)
> 	 result[::2] = x
> 	 result[1::2] = y
> 	 return result

interestingly whilst many of the other solutions can be improved/modernized in 
later pythons this one has stayed the same.
-- 
Robin Becker

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


Thread

Re: Brilliant or insane code? Robin Becker <robin@reportlab.com> - 2015-03-18 15:28 +0000

csiph-web