Path: csiph.com!au2pb.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'binary': 0.05; 'memory.': 0.05; 'additionally': 0.09; 'garbage': 0.09; 'interval,': 0.09; 'libraries.': 0.09; 'python': 0.10; 'subject:python': 0.14; 'interpreter': 0.15; 'subject: \n ': 0.15; 'low-level': 0.16; 'subject:fastest': 0.16; 'memory': 0.17; 'pass': 0.22; 'seems': 0.23; 'header:In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'collecting': 0.27; 'cpu': 0.29; 'extensively': 0.29; 'code': 0.30; 'compiled': 0.32; 'received:google.com': 0.35; 'quite': 0.35; 'should': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'expect': 0.37; 'hi,': 0.38; 'to:addr:python.org': 0.40; 'more': 0.63; 'subject: ( ': 0.84; 'subject:handle': 0.84; 'url:app': 0.84; 'disturb': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=PbibR/JE/j0MtrU2txwRpr4b15qa1XRtUNZSXKGaZZI=; b=ubU+J5lK5MKJkymp+y4yOdCM2ZxcbbmGeydYXhpNEVdU4X4N/y9rLfBD9XPo0Ltf9z WiWTWZ68ylFWkNY3OTFrLcYz5/LZoh6ZVnW5Ld0Fe6NzqN7U1SUQwm1ho8/aRBOo6hHb /uu3yxJ4I1m/ISctnO2RVmN+d/Y6Yckl/uHHWapGnztSAiVcVd1ipYr/tQEv8uEMTTDc cd2KwcXZz3fLUNFwjL4l8ltOGjbt74doHqm/KpBE+d4cDRvbETsUzUoQxiMr2xND/o3k lDhbLgJgPiHsIBGiijP+4w0DTJiyQxnTX4CLJWKuCCBYTbWTDsYGc0mGlr5SlvaaM00r spyA== MIME-Version: 1.0 X-Received: by 10.70.135.233 with SMTP id pv9mr35832689pdb.9.1440331646694; Sun, 23 Aug 2015 05:07:26 -0700 (PDT) In-Reply-To: References: <2aa39ddd-bb07-4a09-a046-a011e215882a@googlegroups.com> Date: Sun, 23 Aug 2015 08:07:26 -0400 Subject: Re: how to handle cpu cache in python ( or fastest way to call a function once) From: Vladimir Ignatov To: python-list@python.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1440331655 news.xs4all.nl 23725 [2001:888:2000:d::a6]:45539 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:95586 Hi, >> for i in range(1000000): #just to create a time interval, seems this disturb cpu cache? >> pass Python interpreter consumes memory quite extensively because "everything is object". So constructions like: range(1000000): _take_ memory. Additionally it will trigger garbage collecting code on deallocation time so expect even more delay. To get most out of Python - all "numbers crushing" / "pixel pushing" / "store gigabytes" code should go to low-level compiled binary libraries. Vladimir https://itunes.apple.com/us/app/python-code-samples/id1025613117