Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'static': 0.04; 'output': 0.05; '22,': 0.09; 'args)': 0.09; 'overflow': 0.09; 'python:': 0.09; 'python': 0.11; 'jan': 0.12; '11:09': 0.16; 'int64': 0.16; 'internally': 0.16; 'overflow.': 0.16; 'url:peps': 0.16; 'values?': 0.16; 'language': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'example': 0.22; 'programming': 0.22; 'to:name:python- list@python.org': 0.22; 'url:dev': 0.24; 'question': 0.24; 'certain': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'void': 0.31; 'url:python': 0.33; '(e.g.': 0.33; 'something': 0.35; 'good.': 0.35; 'received:google.com': 0.35; 'everyone.': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'thank': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'simple': 0.61; 'first': 0.61; 'skip:1 20': 0.65; 'here': 0.66; 'exceed': 0.68; 'philip': 0.95 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=m9PvAuOqKSSRD1FVo+Nla2lJ7exFqjoLEtEMnbyXsrg=; b=ITzvdwJv34XdIOgPyobZMwgo6SPD8kUVF56mBWTP5JyVsK1gXpLUWrdwx2gSJ8kuPM PIlOIS1qVG++94eAR2K+tva2JP75d0JPioD02DgLBJqoJd+8PohhyEaiuIkyaDfxV9aN o9Eslk8p8pCMQXqyVRNKjY/4f3BurOuhaLRJnWlGmb2wWpTmNM37zhuT3l6/zNjDfy2T X1M42HQIuyF0ctK3C+3F1LjLPvigi1hqlRObfcXcIJzWimCPrE6MLlU/+QW60E0NQDT/ lsDmFk0PVeh4WmRoAuJ/WlyVehFU+aznLnK7cOWIMArPouyDEeWvs+zGDOVHjGSpDQkE oNBw== MIME-Version: 1.0 X-Received: by 10.58.200.168 with SMTP id jt8mr1892148vec.30.1390414735791; Wed, 22 Jan 2014 10:18:55 -0800 (PST) In-Reply-To: References: Date: Wed, 22 Jan 2014 11:18:55 -0700 Subject: Re: No overflow in variables? From: Larry Martell To: "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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1390415068 news.xs4all.nl 2841 [2001:888:2000:d::a6]:42173 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64520 On Wed, Jan 22, 2014 at 11:09 AM, Philip Red wrote: > Hi everyone. First of all sorry if my english is not good. > I have a question about something in Python I can not explain: > in every programming language I know (e.g. C#) if you exceed the max-value of a certain type (e.g. a long-integer) you get an overflow. Here is a simple example in C#: > > static void Main(string[] args) > { > Int64 x = Int64.MaxValue; > Console.WriteLine(x); // output: 9223372036854775807 > x = x * 2; > Console.WriteLine(x); // output: -2 (overflow) > Console.ReadKey(); > } > > Now I do the same with Python: > > x = 9223372036854775807 > print(type(x)) # > x = x * 2 # 18446744073709551614 > print(x) # > print(type(x)) > > and I get the right output without overflow and the type is always a 'int'. > How does Python manages internally the types and their values? Where are they stored? > > Thank you for your help :) This may help you understand: http://www.python.org/dev/peps/pep-0237/