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


Groups > comp.lang.python > #87683

Re: Brilliant or insane code?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!bcyclone02.am1.xlned.com!bcyclone02.am1.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.046
X-Spam-Evidence '*H*': 0.91; '*S*': 0.00; 'args': 0.07; 'subject:code': 0.07; 'dan': 0.09; 'lawrence': 0.09; 'worse': 0.09; 'def': 0.12; 'chunks': 0.16; 'it;': 0.16; 'iterates': 0.16; 'itertools': 0.16; 'itself,': 0.16; 'recipe': 0.16; 'work."': 0.16; 'weird': 0.16; 'wrote:': 0.18; 'wed,': 0.18; '(the': 0.22; "i've": 0.25; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'url:bugs': 0.29; 'points': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'relies': 0.31; 'says': 0.33; 'url:python': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'url:org': 0.36; 'detail': 0.37; 'url:library': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'according': 0.40; 'url:3': 0.61; 'guarantee': 0.63; 'zip': 0.64; 'mar': 0.68; 'fact,': 0.69; 'url:4': 0.69; 'opinions': 0.70; 'article': 0.77; '"it': 0.84; '2015': 0.84; 'abc': 0.84; 'guaranteed.': 0.84; 'url:posts': 0.84; 'sitting': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=wtYyWgm7fjdaWlXBfT9k9/cTw26O47Jxc+juiPKWycU=; b=xlAL5jc/3TNWuVXTTpweOxTktZ216IqYtqjUDBbgMvHlwZ5d/YQ5yaqTAEDG0Ex7DM t7aEwFnQlnE36UKHPeJ4Sk1x0b2AMxhkub+pujumFnM9m6Yi8+0hGYNUxHebP5ce7dDR A6jqwbef5zb/1SfHFam69cv3wnHNAjEKDw04XBdlA505BA/sk1/oXX3kJ1uORaM+oQdJ 4DNfuxKnxQd9eUutMo0TFeeQYxvio1zD7v3z5jMZZ0LkB/vbGlC2hFIUsPIAEvAj4D3/ meD2sf9A0L94Yj4wf2oESQu1b/cICBGHx7bSVJT7nLJWoFC6jkzhwxuzw8PGbVjkwPHN oiyg==
X-Received by 10.66.161.161 with SMTP id xt1mr163705679pab.35.1426690840143; Wed, 18 Mar 2015 08:00:40 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <meajh1$hr0$2@dont-email.me>
References <mailman.507.1426638964.21433.python-list@python.org> <meajh1$hr0$2@dont-email.me>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Wed, 18 Mar 2015 08:59:59 -0600
Subject Re: Brilliant or insane code?
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
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.3.1426690849.10327.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1426690849 news.xs4all.nl 2893 [2001:888:2000:d::a6]:34265
X-Complaints-To abuse@xs4all.nl
X-Received-Bytes 4413
X-Received-Body-CRC 1349568080
Xref csiph.com comp.lang.python:87683

Show key headers only | View raw


On Tue, Mar 17, 2015 at 7:14 PM, Dan Sommers <dan@tombstonezero.net> wrote:
> On Wed, 18 Mar 2015 00:35:42 +0000, 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.
>
> According to the article itself, "it relies in an implementation detail
> (the order the zip function iterates over the arrays) to work."  Then
> again, the article also points to the official docs that says that this
> implementation detail is guaranteed.
>
> So it's no worse than depending on some weird but *documented* corner of
> the IEEE-754 or POSIX spec.

In fact, this is also a code recipe found in the itertools
documentation. The official docs don't just guarantee it; they
*recommend* it.

def grouper(iterable, n, fillvalue=None):
    "Collect data into fixed-length chunks or blocks"
    # grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx"
    args = [iter(iterable)] * n
    return zip_longest(*args, fillvalue=fillvalue)

https://docs.python.org/3.4/library/itertools.html

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


Thread

Brilliant or insane code? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-03-18 00:35 +0000
  Re: Brilliant or insane code? Dan Sommers <dan@tombstonezero.net> - 2015-03-18 01:14 +0000
    Re: Brilliant or insane code? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-18 13:25 +1100
      Re: Brilliant or insane code? Dan Sommers <dan@tombstonezero.net> - 2015-03-18 03:06 +0000
    Re: Brilliant or insane code? Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-18 08:59 -0600
    Re: Brilliant or insane code? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-03-18 15:20 +0000

csiph-web