Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin.stu.neva.ru!news.swapon.de!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.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; 'algorithm': 0.04; 'languages.': 0.04; 'python)': 0.05; 'subject:Python': 0.06; 'processing.': 0.07; 'converted': 0.09; 'doing?': 0.09; 'occasionally': 0.09; 'python': 0.11; '-tkc': 0.16; 'bound,': 0.16; 'code?': 0.16; 'folks,': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'personally,': 0.16; 'python),': 0.16; 'python;': 0.16; 'pythonic': 0.16; 'rarely': 0.16; 'sorts': 0.16; 'wrote:': 0.18; 'memory': 0.22; 'issue,': 0.24; 'tend': 0.24; 'java': 0.24; "i've": 0.25; 'switch': 0.26; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; 'code': 0.31; '(usually': 0.31; 'libraries': 0.31; 'checking': 0.33; 'noticed': 0.34; 'could': 0.34; 'problem': 0.35; 'classes': 0.35; 'operations': 0.35; 'but': 0.35; 'charset:us- ascii': 0.36; 'application': 0.37; 'performance': 0.37; '(i.e.,': 0.38; 'to:addr:python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'algorithms': 0.60; 'most': 0.60; 'received:50.22': 0.84; 'trouble.': 0.91 Date: Sat, 8 Mar 2014 07:40:48 -0600 From: Tim Chase To: python-list@python.org Subject: Re: Python performance In-Reply-To: <290bb6ed-a17e-45e3-8ff7-e58bb50e66a6@googlegroups.com> References: <290bb6ed-a17e-45e3-8ff7-e58bb50e66a6@googlegroups.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Get-Message-Sender-Via: boston.accountservergroup.com: authenticated_id: tim@thechases.com X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1394286032 news.xs4all.nl 2894 [2001:888:2000:d::a6]:60034 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68038 On 2014-03-08 04:53, JCosta wrote: > I did some work in c# and java and I converted some application to > Python; I noticed Python is much slower than the other languages. > > Is this normal ? It depends. Did you write C#/Java in Python (i.e., use C# or Java idioms in Python), or did you write Pythonic code? Check your algorithms and storage classes for performance characteristics (if you used an O(1) algorithm/container in C#/Java but used an O(N) algorithm/container in Python) and make sure they match. What sorts of operations are you doing? Are you CPU-bound, I/O bound, or memory-bound? Have you profiled to see where the hot-spots are? Personally, I've found that most of my code is I/O-bound (disk or network), and that very rarely has CPU been much of a problem (usually checking my algorithm if there's trouble; occasionally I'm stuck with an O(N^2) algorithm and no language-choice. For some folks, using one of the specialty-math libraries can speed up numeric processing. If I know that memory could be an issue, I tend to switch to a disk-based data-stores to head off any trouble. -tkc