Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'exception': 0.03; 'interpreter': 0.04; 'memory.': 0.05; 'bug.': 0.07; 'python': 0.09; '32-bit': 0.09; 'exited': 0.09; 'indexes': 0.09; 'itself,': 0.09; 'porting': 0.09; 'subclass': 0.09; 'subject:()': 0.09; 'unexpected': 0.09; 'bug': 0.10; '2.7': 0.13; 'crashed': 0.16; 'fits': 0.16; 'mistake.': 0.16; 'oct': 0.16; 'operation,': 0.16; 'received:72.167.82.81': 0.16; 'received:p3plsmtpa01-01.prod.phx3.secureserver.net': 0.16; 'redo': 0.16; 'routinely': 0.16; 'slice,': 0.16; 'subject:array': 0.16; 'wrote:': 0.17; 'copied': 0.17; 'issue,': 0.17; 'processor': 0.17; 'java': 0.21; '3.x': 0.22; 'libraries': 0.22; "i'd": 0.22; 'nearly': 0.23; 'pass': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'embedded': 0.27; 'possibly': 0.27; 'realize': 0.27; 'all.': 0.28; 'run': 0.28; 'about.': 0.29; 'attempted': 0.29; 'occasional': 0.29; 'overhead': 0.29; 'received:72.167.82': 0.29; 'case,': 0.29; 'no,': 0.29; 'url:code': 0.29; 'probably': 0.29; 'class': 0.29; 'that.': 0.30; 'error': 0.30; 'lists': 0.31; 'system,': 0.32; 'running': 0.32; 'anywhere': 0.33; 'curious': 0.33; 'shorter': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'likely': 0.33; 'typically': 0.33; 'version': 0.34; "can't": 0.34; 'list': 0.35; "won't": 0.35; 'there': 0.35; 'list.': 0.35; 'really': 0.36; 'alone': 0.36; 'method': 0.36; 'itself': 0.37; 'does': 0.37; 'uses': 0.37; 'being': 0.37; 'why': 0.37; 'virtual': 0.37; 'subject:: ': 0.38; 'positive': 0.38; 'some': 0.38; 'delete': 0.38; 'system.': 0.39; 'to:addr:python.org': 0.39; 'space': 0.39; 'think': 0.40; 'your': 0.60; 'received:network': 0.61; 'course.': 0.62; 'received:phx3.secureserver.net': 0.62; 'received:prod.phx3.secureserver.net': 0.62; 'url:p': 0.63; 'received:unknown': 0.63; 'ever': 0.63; 'more': 0.63; 'become': 0.65; 'due': 0.66; 'header:Reply-To:1': 0.68; 'behaviors': 0.71; 'million': 0.72; 'reply-to:no real name:2**0': 0.72; 'power': 0.74; 'low': 0.83; 'behaviors.': 0.91 Date: Mon, 29 Oct 2012 08:42:39 -0700 From: Andrew Robinson User-Agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111126 Thunderbird/8.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Negative array indicies and slice() References: <6998a955-7b34-4f4f-b8d6-62d1028f7561@googlegroups.com> <4c024364-84df-403b-8b9e-4a4c8f06121c@googlegroups.com> <508e6649$0$29967$c3e8da3$5496439d@news.astraweb.com> <508E1BC9.3000308@r3dsolutions.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: andrew3@r3dsolutions.com 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: 46 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351550917 news.xs4all.nl 6948 [2001:888:2000:d::a6]:54409 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32434 On 10/29/2012 10:09 AM, Ian Kelly wrote: > On Oct 29, 2012 7:10 AM, "Andrew Robinson" wrote: >> I will be porting Python 3.xx to a super low power embedded processor (MSP430), both space and speed are at a premium. >> Running Python on top of Java would be a *SERIOUS* mistake. .NET won't even run on this system. etc. > If that's the case, then running Python at all is probably a mistake. > You know the interpreter alone has an overhead of nearly 6 MB? There's already a version of the python interpreter which fits in under 100K: http://code.google.com/p/python-on-a-chip/ It's not the 3.x series, though; and I don't want to redo this once 2.7 really does become obsolete. >> Yes, I realize that. >> But, why can't I just overload the existing __getitem__ for lists and not bother writing an entire class? > You can just overload that one method in a subclass of list. Being > able to monkey-patch __getitem__ for the list class itself would not > be advisable, as it would affect all list slicing anywhere in your > program and possibly lead to some unexpected behaviors. That's what I am curious about. What unexpected behaviors would a "monkey patch" typically cause? If no one really uses negative and positive indexes in the same slice operation, because there is no reason to do so... It will only break the occasional esoteric application. > > 20 million is nothing. On a 32-bit system, sys.maxsize == 2 ** 31 - > 1. If the error you were seeing was MemoryError, then more likely you > were running into dynamic allocation issues due to fragmentation of > virtual memory. > > No, there was no error at all. Pthon just crashed & exited; not even an exception that I can recall. It was if it exited normally! The list was generated in a single pass by many .append() 's, and then copied once -- the original was left in place; and then I attempted to slice it. I am able to routinely to 5 million length lists, copy, slice, cut, append, and delete from them without this ever happening. If fragmentation were the issue, I'd think the shorter lists would cause the problem after many manipulations... It may not be a bug in python itself, though, of course. There are libraries it uses which might have a bug.