Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.news-service.com!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:using': 0.04; 'subject:code': 0.07; 'argument,': 0.09; 'builtin': 0.09; 'question:': 0.09; 'subject:error': 0.11; '__builtins__': 0.16; 'subject: \n ': 0.16; 'subject:builtin': 0.16; 'subject:import': 0.16; 'subject:sum': 0.16; '>>>': 0.16; 'received:internal': 0.19; 'appropriate': 0.20; 'header:In-Reply-To:1': 0.22; 'globally': 0.23; 'received:10.202': 0.23; 'received:10.202.2': 0.23; 'received:66.111': 0.23; 'received:66.111.4': 0.23; 'received:messagingengine.com': 0.23; 'received:smtp.messagingengine.com': 0.23; "shouldn't": 0.23; 'code': 0.24; 'function': 0.26; 'import': 0.29; 'module': 0.30; 'offending': 0.30; 'subject:?': 0.31; 'to:addr:python-list': 0.34; 'e.g.': 0.34; 'test': 0.34; 'replacement': 0.35; 'uses': 0.35; 'issue': 0.37; 'friday,': 0.37; 'but': 0.37; 'could': 0.37; 'received:192': 0.38; 'subject:: ': 0.38; 'purposes': 0.38; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'july': 0.64; 'said:': 0.67; 'message-id:@localhost.localdomain': 0.76; '19:17': 0.84; 'sum': 0.89 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=subject:from:to:date:in-reply-to:references:content-type:content-transfer-encoding:message-id:mime-version; s=smtpout; bh=00PW1lrzOY15qO9RaD05IinVaOc=; b=gqEXkiuIQzeovc7fKEvVlnDpZB+/XnkCJIbQWQJBEvyTNd7DmvEjGtgJpb+TZCShoCiQ9tA1zYXVr+TCizyAzQNLOptnrnmJQhMrnFI2NxqoXXS5Gnp4otYCXcHx9R5cfOO1sLGHT1qC0MJjhGXOX4PZ2pgPvXiLa0zWpgcf3FU= X-Sasl-enc: he5+0yOUqbhNBFaExqOKNL4w6Ioz9eLruoZ2WXh72Czf 1309575251 Subject: Re: subtle error slows code by 10x (builtin sum()) - replace builtin sum without using import? From: Albert Hopkins To: python-list@python.org Date: Fri, 01 Jul 2011 22:54:10 -0400 In-Reply-To: References: Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAAXNSR0IArs4c6QAAADBQTFRF1///CwsLGxsbJycnNzc3RUVFU1NTYmJicXFxf39/jIyMm5ubq6urubm5yMjI3t7eukg4JQAAAAF0Uk5TAEDm2GYAAAIoSURBVDhPpZC9btRQEEbPGIJQhOIZB4SEhGJ7W/42lihoKCJ6agoeglfgDXiQPAGEio5sKGgTLxRIFNk7DigV7FD4J4SW23jud+75ZA38x9ncnb3wf0PgjZnZdvo35rVZZWa3RiLDd+PGMNz5oABkw/2e9ne+HTgwGRt3nejHzc8Gk/EURfvx/IgLcK3YNZWB7C8vwFqtqcxEAPYD4CoAr5xUiBaJlfOrvTA+IRLqLhisWx/B9RItzckjHCJNxtqKGhRBgEiTAWCIBqGXDNBODEdBIWIEgquCiosD6GQsTYzAVVUAH0FCFDPP3ce8Byenx0hhFRBoX5cBFPXJUVILUog6rTOs5Mv5DnGyOAaXHMvb0fiU3z8QbNZAjmg5VXVbP/N0uHhyWJrAl8RYhebzVcq+K4CJ2WgomSbWsSsguRY6GtncD0N0EYImEcrRkPUxXcrKflNYN4LUmqKndQVOV5qOIDp5Vhb518oEqqxgBFuyOhSKlRF4NptPhp22Ee0ylnioNfVkPPLSix1SG9BJrRN4aFcevfNIKw8f8h5k8vtsnlUauSBiF2DD6/ePd5LPAOvzHpw97F6+dbHOk1T1X4DnXN2rlF+OWKXAuN3Cj3HHNW5u/13FzeQtEkv/YU0vDCATjZSn8KqZXwLdA3Kny+q6GZoGwPPFmZ5oNWt29TK4/XSVpK6bPRny4a+Qx1+FrNkrdATji/XHhdTbw55gMrC0TaFTEfwB/cbNxoZIacsAAAAASUVORK5CYII= Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.0.2 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1309575260 news.xs4all.nl 21847 [2001:888:2000:d::a6]:39056 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:8654 On Friday, July 1 at 19:17 (-0700), bdb112 said: > Question: > Can I replace the builtin sum function globally for test purposes so > that my large set of codes uses the replacement? > > The replacement would simply issue warnings.warn() if it detected an > ndarray argument, then call the original sum > I could then find the offending code and use the appropriate import to > get numpy.sum You shouldn't do this, but you could use the __builtins__ module e.g. >>> __builtins__.sum = numpy.sum # bad