Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #11115 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2011-08-10 13:32 +0100 |
| Last post | 2011-08-10 13:32 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: String concatenation - which is the fastest way ? Chris Angelico <rosuav@gmail.com> - 2011-08-10 13:32 +0100
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2011-08-10 13:32 +0100 |
| Subject | Re: String concatenation - which is the fastest way ? |
| Message-ID | <mailman.2100.1312979528.1164.python-list@python.org> |
On Wed, Aug 10, 2011 at 12:17 PM, <przemolicc@poczta.fm> wrote: > Hello, > > I'd like to write a python (2.6/2.7) script which connects to database, fetches > hundreds of thousands of rows, concat them (basically: create XML) > and then put the result into another table. Do I have any choice > regarding string concatenation in Python from the performance point of view ? > Since the number of rows is big I'd like to use the fastest possible library > (if there is any choice). Can you recommend me something ? First off, I have no idea why you would want to create an XML dump of hundreds of thousands of rows, only to store it in another table. However, if that is your intention, list joining is about as efficient as you're going to get in Python: lst=["asdf","qwer","zxcv"] # feel free to add 399,997 more list entries xml="<foo>"+"</foo><foo>".join(lst)+"</foo>" This sets xml to '<foo>asdf</foo><foo>qwer</foo><foo>zxcv</foo>' which may or may not be what you're after. ChrisA
Back to top | Article view | comp.lang.python
csiph-web