Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63951 > unrolled thread
| Started by | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| First post | 2014-01-14 17:07 -0500 |
| Last post | 2014-01-14 17:07 -0500 |
| 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: L[:] Terry Reedy <tjreedy@udel.edu> - 2014-01-14 17:07 -0500
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2014-01-14 17:07 -0500 |
| Subject | Re: L[:] |
| Message-ID | <mailman.5485.1389737406.18130.python-list@python.org> |
On 1/14/2014 5:42 AM, Albert-Jan Roskam wrote: > I also found that item assignment ([1] below) is much faster > than using the more standard (I think) .append ([2]). > # [1] > for idx,item in enumerate(L[:]): > if some_condition: > L[idx] = foobarify(item) [1] *is* the standard way to selectively replace items. > # [2] > L2 = [] > for idx,item in enumerate(L): > if some_condition: > L2.append(foobarify(item)) > else: > L2.append(item) -- Terry Jan Reedy
Back to top | Article view | comp.lang.python
csiph-web