Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.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.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'python,': 0.02; '16,': 0.03; 'initialize': 0.07; 'subject:code': 0.07; 'way:': 0.09; 'cc:addr:python-list': 0.11; '11:59': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'integer.': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'do.': 0.18; "python's": 0.19; 'seems': 0.21; 'feb': 0.22; 'machine': 0.22; 'python?': 0.22; 'cc:addr:python.org': 0.22; 'integer': 0.24; 'cc:2**0': 0.24; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'function': 0.29; 'message-id:@mail.gmail.com': 0.30; 'guess': 0.33; 'not.': 0.33; "can't": 0.35; 'no,': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'ram': 0.36; 'possible': 0.36; 'similar': 0.36; 'whatever': 0.38; 'pm,': 0.38; 'rather': 0.38; 'anything': 0.39; 'enough': 0.39; 'conversion': 0.61; 'simply': 0.61; "you'll": 0.62; 'close': 0.67; 'limit': 0.70; 'obvious': 0.74; 'other.': 0.75; 'conversion?': 0.84; 'rita': 0.84; 'subject:base': 0.84; 'to:none': 0.92 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:cc :content-type; bh=tDuwjIQoiwkF0Db7/oNeh2AB9zfMO6VOabPsKcGXjp8=; b=dUrR83DPUTX3ogH9phpT3Ew1lNW2Gu6itSLBtoSgnC5XPnvwNKdWspaGfsflMAuGnN huvOOe+VZFcUcgjKDh5dVXaYS+gfEzX7fNN/uAbKhA9s5OOVuym/GBwPVLqb16n9XytR uij16ej+UT78V5wzYvOOM3+JmLLr0RbNRToHwPeDX6ZX6qxKFKVfzkKAB87S3ZF+St3a hB+H+QVAip+V+OaAos+oMGAgkQqDfUTJo8rapN/fiUvIah4902bVsvLX7/RdSEkwXd4S A7Q3652rU6opmWx2Qsuf5w0l8hLjGEf1NRbfozVUO+8gHL1kscDYPEbyKLBh6w7Vxm/d 7ZcA== MIME-Version: 1.0 X-Received: by 10.66.102.39 with SMTP id fl7mr20337593pab.43.1392557216218; Sun, 16 Feb 2014 05:26:56 -0800 (PST) In-Reply-To: References: Date: Mon, 17 Feb 2014 00:26:55 +1100 Subject: Re: inheriting a large python code base From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392557224 news.xs4all.nl 2854 [2001:888:2000:d::a6]:51357 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66533 On Sun, Feb 16, 2014 at 11:59 PM, Rita wrote: > when I do profiling is it possible to find out if I am spending a lot of > time in type conversion? > it seems I am not. I would guess that you don't. But in Python, type conversion is like any other function call: value = int("12345") So you can test for it the same way you would any other. > Also, is it possible to predeclare a type in python? > Similar to C: int i=0; > No, because in Python, variables/names don't have types - only objects/values do. You can simply initialize i to 0, in the obvious way: i = 0 And if you never put anything but an integer into i, it'll always be an integer. That's about as close as you'll get to an "integer variable" like C has. (Python's idea of an integer is rather better than C's, of course; C's 'int' type is a machine word, so it can't store values greater than 2**32 or 2**64 or whatever the limit is, but Python's int can store any integer you have RAM enough to store.) ChrisA