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


Groups > comp.lang.python > #11263

Re: String concatenation - which is the fastest way ?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.040
X-Spam-Evidence '*H*': 0.92; '*S*': 0.00; 'example:': 0.03; "'w',": 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'slicing.': 0.16; 'wrote:': 0.16; '>>>': 0.18; 'header:In-Reply- To:1': 0.22; 'interface': 0.23; '+0100,': 0.23; 'slice': 0.23; 'pm,': 0.24; 'aug': 0.24; 'skip:" 30': 0.28; 'thu,': 0.28; 'oracle': 0.29; 'message-id:@mail.gmail.com': 0.29; 'operations': 0.30; 'strings.': 0.30; 'chris': 0.32; 'list': 0.32; 'actually': 0.33; 'to:addr:python-list': 0.33; '...': 0.34; 'quite': 0.34; 'subject: ?': 0.34; 'created': 0.36; 'run': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'to:addr:python.org': 0.39; 'your': 0.61; 'straight': 0.63; '11,': 0.68; "'f',": 0.84; '10000': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=dXjAPnMXheJJmavrm2H7PcZMLP4mFKOf7pdND40tk64=; b=OnpcbFU9PeJ5TRXZJVldUE4vv4WGhp0vcZhFLzhJNXbm3TWuMggbTzcKX4ohlZfkdB Rqr/VR13O2VdJBlpaVtjx8AgVJ2FyrUPbQUjBUV+6Y1VEM8+BZPklf9wpvHDtZSgAWI5 y3b/AEa+uL3OQedt/iEZsp3yCD5kMNTAdHIE0=
MIME-Version 1.0
In-Reply-To <20110811143923.GG4990@host.pgf.com.pl>
References <20110810111754.GD5045@host.pgf.com.pl> <CAPTjJmrF0GcVs0onfoCHAbMe38b5iLXgFX1R7G_RXcKxjPH5wQ@mail.gmail.com> <20110810133146.GE5045@host.pgf.com.pl> <j1ub3q$65c$1@dough.gmane.org> <20110811064030.GB4990@host.pgf.com.pl> <CAPTjJmqiiKcT7Zg-XkbrQ4r-keU9+1Kj=+sEwa4xp==2EG-5aQ@mail.gmail.com> <20110811134613.GE4990@host.pgf.com.pl> <CAPTjJmr7qDeGU+ttEXsdBOASqZ5w1mYgkg18o+RtFp55HHp8Ew@mail.gmail.com> <20110811143923.GG4990@host.pgf.com.pl>
Date Fri, 12 Aug 2011 10:20:41 +0100
Subject Re: String concatenation - which is the fastest way ?
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2212.1313140844.1164.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1313140844 news.xs4all.nl 23915 [2001:888:2000:d::a6]:37986
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:11263

Show key headers only | View raw


On Thu, Aug 11, 2011 at 3:39 PM,  <przemolicc@poczta.fm> wrote:
> On Thu, Aug 11, 2011 at 02:48:43PM +0100, Chris Angelico wrote:
>> List of strings. Take it straight from your Oracle interface and work
>> with it directly.
>
> Can I use this list in the following way ?
> subprocess_1 - run on list between 1 and 10000
> subprocess_2 - run on list between 10001 and 20000
> subprocess_3 - run on list between 20001 and 30000
> etc
> ...

Yep! You use list slicing. Working with smaller numbers for an example:

>>> ltrs=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
>>> ltrs[:10]
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
>>> ltrs[10:20]
['k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't']
>>> ltrs[20:]
['u', 'v', 'w', 'x', 'y', 'z']

(I actually created that list as "list(string.ascii_lowercase)" for
what that's worth.)

Slice operations are quite efficient.

Chris Angelico

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


Thread

Re: String concatenation - which is the fastest way ? Chris Angelico <rosuav@gmail.com> - 2011-08-12 10:20 +0100

csiph-web