Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #95035

QUEST: does HACKING make FOR loop quicker.

Path csiph.com!goblin3!goblin.stu.neva.ru!gegeweb.org!news.redatomik.org!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <z2911@bk.ru>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.029
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'modified': 0.05; 'that?': 0.05; 'sequences.': 0.07; '[0,': 0.09; 'logic': 0.09; 'mutable': 0.09; 'skip:= 70': 0.10; 'output': 0.13; 'appropriate': 0.14; 'list)': 0.16; 'preamble': 0.16; 'subject:make': 0.16; 'subtlety': 0.16; 'hacking': 0.18; 'pass': 0.22; '(this': 0.24; 'header:User- Agent:1': 0.26; 'example': 0.26; 'external': 0.27; 'question': 0.27; 'sequence': 0.27; 'wind': 0.29; 'work.': 0.30; 'skip:+ 70': 0.33; 'lists': 0.34; 'list': 0.34; 'so,': 0.35; 'i.e.': 0.35; 'sometimes': 0.35; 'community': 0.36; 'but': 0.36; 'list,': 0.36; 'instead': 0.36; 'there': 0.36; 'depends': 0.36; 'smaller': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'means': 0.39; 'does': 0.39; 'skip:x 10': 0.40; 'to:addr:python.org': 0.40; 'your': 0.60; 'information,': 0.61; 'please,': 0.63; 'skip:* 70': 0.70; 'operated': 0.72; 'received:93': 0.72; 'received:ru': 0.81; '(depends': 0.84; 'answer:': 0.84; 'presumption': 0.84; 'village': 0.84; 'subject:FOR': 0.95
DKIM-Signature v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=bk.ru; s=mail; h=Content-Transfer-Encoding:Content-Type:Subject:To:MIME-Version:From:Date:Message-ID; bh=7coQ8jA+eXqzpBkPfcH4ixkAk04ZCB8sejnMcDF+vNU=; b=tOV35IBPExkJ4WwAAct9lSZucdOvmN1a3o5JqlcAPcuY95ArFsSYVuhksJHhTaqckCYWyMVFlpMJbAR8OUkym/0iKGnWC1Yi2S2Zrs4IQGrebzcBdw5LURBLH/zfuTMkWryqcXP3q6Vuo/UPDhdc1UgZq7eI8TsCg0drRjG9el4=;
Date Wed, 05 Aug 2015 23:00:23 +0300
From John Doe <z2911@bk.ru>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1
MIME-Version 1.0
To python-list@python.org
Subject QUEST: does HACKING make FOR loop quicker.
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Mras Ok
X-Mailman-Approved-At Wed, 05 Aug 2015 22:40:27 +0200
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1246.1438807229.3674.python-list@python.org> (permalink)
Lines 49
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1438807229 news.xs4all.nl 2911 [2001:888:2000:d::a6]:35615
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:95035

Show key headers only | View raw


Presumption
------------------------------------------------------------------------
1. Lists are mutable sequences.
2. There is a subtlety when the sequence is being modified by the FOR 
loop (this can only occur for mutable sequences, i.e. lists)


Preamble
=====================================================================
To pass by reference or by copy of - that is the question from hamlet. 
("hamlet" - a community of people smaller than a village python3.4-linux64)

xlist = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
i = 0
for x in xlist:
     print(xlist)
     print("\txlist[%d] = %d" % (i, x))
     if x%2 == 0 :
         xlist.remove(x)
     print(xlist, "\n\n")
     i = i + 1

So, catch the output and help me, PLEASE, improve the answer:
Does it appropriate ALWAYS RE-evaluate the terms of the expression list 
in FOR-scope on each iteration?
But if I want to pass ONCE a copy to FOR instead of a reference (as seen 
from an output) and reduce unreasonable RE-evaluation, what I must to do 
for that?
========================================================================


Assumption. Wind of changes.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Sometimes FOR-loop may do a global work. (depends on size of expression 
list)
Sometimes on external DB. (just a joke)

So, what can FOR-loop do for You, depends what can You do for expression 
list, which can be mutable far outside YOUR NICE LOGIC.


QUEST
************************************************************************
Your example of FOR-loop with a simple logic and sensitive information, 
operated by means of external list-array and Your elaborative vision of 
hacking possibilities through mutation of a list's terms.

TIA
RSVP

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

QUEST: does HACKING make FOR loop quicker. John Doe <z2911@bk.ru> - 2015-08-05 23:00 +0300

csiph-web