Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '(although': 0.05; 'attribute': 0.07; 'exec': 0.07; 'python': 0.08; 'dynamically': 0.09; 'figuring': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'readable': 0.09; 'reason?': 0.09; 'received:gator410.hostgator.com': 0.09; '~ethan~': 0.09; 'cc:addr:python-list': 0.15; 'code).': 0.16; 'input.': 0.16; 'objects).': 0.16; 'received:72.11': 0.16; 'received:72.11.125': 0.16; 'received:72.11.125.166': 0.16; 'subject:() ': 0.16; 'wrote:': 0.18; 'reason,': 0.18; 'figure': 0.20; 'later': 0.21; 'cc:no real name:2**0': 0.21; 'primarily': 0.21; 'name?': 0.23; 'header:In-Reply-To:1': 0.23; 'cc:2**0': 0.25; 'code': 0.25; 'code.': 0.26; 'fine': 0.26; 'function': 0.27; 'somebody': 0.27; 'fine.': 0.28; 'cc:addr:python.org': 0.29; 'pattern': 0.30; '(e.g.': 0.30; 'subject:?': 0.31; 'certainly': 0.32; 'does': 0.32; "can't": 0.32; 'there': 0.33; 'header:User-Agent:1': 0.33; 'on,': 0.33; 'setting': 0.34; 'approach.': 0.34; 'sense,': 0.34; 'things': 0.35; "what's": 0.35; 'object': 0.35; 'certain': 0.35; 'like,': 0.36; 'limitation': 0.36; 'issue': 0.37; 'think': 0.37; 'some': 0.38; "it's": 0.39; 'why': 0.39; 'subject:: ': 0.39; 'being': 0.40; 'supports': 0.40; 'really': 0.40; 'more': 0.60; 'results': 0.61; 'projects': 0.62; 'received:websitewelcome.com': 0.64; 'received:184': 0.67; 'virtually': 0.73; 'troubles': 0.84; 'to:none': 0.93 Date: Thu, 10 Nov 2011 10:43:32 -0800 From: Ethan Furman User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 CC: python-list@python.org Subject: Re: all() is slow? References: <436fb6a3-1075-45a6-8f93-5612d050b11a@q35g2000prh.googlegroups.com> <4eb9e9c2$0$29988$c3e8da3$5496439d@news.astraweb.com> <4ebb08b6$0$29970$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: mail.admailinc.com ([192.168.10.136]) [72.11.125.166]:2132 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 2 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1320951665 news.xs4all.nl 6947 [2001:888:2000:d::a6]:37190 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:15553 Devin Jeanpierre wrote: > Well. It reads fine in a certain sense, in that I can figure out > what's going on (although I have some troubles figuring out why the > heck certain things are in the code). The issue is that what's going > on is otherworldly: this is not a Python pattern, this is not a normal > approach. To me, that means it does not read fine. Certainly it's a Python pattern -- it's what you do to dynamically generate code. > The use of exec also results in (seemingly) arbitrary constraints on > the input. Like, why can't "--" be a name? Because exec? Is there some > other reason? '--' not being allowed for a name has *nothing* to do with exec, and everything to do with `--` not being a valid Python identifier. > '--' is a valid attribute name on virtually any object that supports > attribute setting (e.g. function objects). Of course, you need to use > setattr() and getattr(). Is this really the reason, or is it a > limitation caused primarily by the usage of exec and the need to > prevent code injection? If somebody added this feature later on, would > this create a security vulnerability in certain projects that used > namedtuple in certain ways? So you think somevar = getattr(my_named_tuple, '--') is more readable than somevar = my_named_tuple.spam ? ~Ethan~