Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'that?': 0.05; 'python': 0.09; 'later)': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'message-id:@dough.gmane.org': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'stefan': 0.17; '(or': 0.18; 'code.': 0.20; 'seems': 0.23; 'second': 0.24; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints- To:1': 0.28; 'depth': 0.29; 'necessary,': 0.29; 'maybe': 0.29; 'function': 0.30; 'code': 0.31; 'to:addr:python-list': 0.33; 'so,': 0.35; 'there': 0.35; 'received:org': 0.36; 'really': 0.36; 'but': 0.36; 'subject:: ': 0.38; 'object': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'first': 0.61; 'taking': 0.65; 'functions)': 0.84; 'step.': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Stefan Behnel Subject: Re: profiling and optimizing Date: Tue, 31 Jul 2012 14:22:23 +0200 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: fw-snc-frn5-de01.fw.telefonica.de User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 In-Reply-To: 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1343737365 news.xs4all.nl 6886 [2001:888:2000:d::a6]:43907 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:26305 Rita, 31.07.2012 14:13: > I recently inherented a large python process and everything is lovely. As a > learning experience I would like to optimize the code so I ran it thru the > profiler > > python -m cProfile myscript.py > > It seems majority of the time is taking in the deep copy but that seems to > come from a function (or functions) in the code. Is there a way to optimize > that? perhaps have a C implementation of the deep copy? Would that > be feasible? Those approaches would be my second (or maybe even later) step. The first one would be to check if the deep copy is really necessary, and if so, if it is really necessary to do it over the full depth of the entire object graph. Stefan