Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #50900 > unrolled thread
| Started by | Devyn Collier Johnson <devyncjohnson@gmail.com> |
|---|---|
| First post | 2013-07-19 09:22 -0400 |
| Last post | 2013-07-21 13:49 +0100 |
| Articles | 3 on this page of 23 — 8 participants |
Back to article view | Back to comp.lang.python
Find and Replace Simplification Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-19 09:22 -0400
Re: Find and Replace Simplification Novocastrian_Nomad <gregory.j.baker@gmail.com> - 2013-07-19 06:38 -0700
Re: Find and Replace Simplification John Gordon <gordon@panix.com> - 2013-07-19 14:28 +0000
Re: Find and Replace Simplification Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-19 16:22 +0000
Re: Find and Replace Simplification Serhiy Storchaka <storchaka@gmail.com> - 2013-07-19 20:29 +0300
Re: Find and Replace Simplification Skip Montanaro <skip@pobox.com> - 2013-07-19 13:08 -0500
Re: Find and Replace Simplification Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-19 17:44 -0400
Re: Find and Replace Simplification Dave Angel <davea@davea.name> - 2013-07-19 18:45 -0400
Re: Find and Replace Simplification Joshua Landau <joshua@landau.ws> - 2013-07-20 12:16 +0100
Re: Find and Replace Simplification Serhiy Storchaka <storchaka@gmail.com> - 2013-07-20 14:48 +0300
Re: Find and Replace Simplification Serhiy Storchaka <storchaka@gmail.com> - 2013-07-20 14:57 +0300
Re: Find and Replace Simplification Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-20 08:41 -0400
Re: Find and Replace Simplification Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-20 08:50 -0400
Re: Find and Replace Simplification Joshua Landau <joshua@landau.ws> - 2013-07-20 18:03 +0100
Re: Find and Replace Simplification Dave Angel <davea@davea.name> - 2013-07-20 14:04 -0400
Re: Find and Replace Simplification Joshua Landau <joshua@landau.ws> - 2013-07-20 19:37 +0100
Re: Find and Replace Simplification Joshua Landau <joshua@landau.ws> - 2013-07-20 19:41 +0100
Re: Find and Replace Simplification Dave Angel <davea@davea.name> - 2013-07-20 17:56 -0400
Re: Find and Replace Simplification Joshua Landau <joshua@landau.ws> - 2013-07-20 23:33 +0100
Re: Find and Replace Simplification Serhiy Storchaka <storchaka@gmail.com> - 2013-07-21 10:44 +0300
Re: Find and Replace Simplification Joshua Landau <joshua@landau.ws> - 2013-07-21 12:29 +0100
Re: Find and Replace Simplification Serhiy Storchaka <storchaka@gmail.com> - 2013-07-21 15:28 +0300
Re: Find and Replace Simplification Joshua Landau <joshua@landau.ws> - 2013-07-21 13:49 +0100
Page 2 of 2 — ← Prev page 1 [2]
| From | Joshua Landau <joshua@landau.ws> |
|---|---|
| Date | 2013-07-21 12:29 +0100 |
| Message-ID | <mailman.4949.1374406214.3114.python-list@python.org> |
| In reply to | #50914 |
On 21 July 2013 08:44, Serhiy Storchaka <storchaka@gmail.com> wrote: > 20.07.13 20:03, Joshua Landau написав(ла): > >> Still, it seems to me that it should be optimizable for sensible >> builtin types such that .translate is significantly faster, as there's >> no theoretical extra work that .translate *has* to do that .replace >> does not, and .replace also has to rebuild the string a lot of times. > > You should analyze overall mapping and reorder items in right order (if it > possible), i.e. '&' should be replaced before '<' in html.escape. This extra > work is too large for most real input. I don't understand. What items are you reordering?
[toc] | [prev] | [next] | [standalone]
| From | Serhiy Storchaka <storchaka@gmail.com> |
|---|---|
| Date | 2013-07-21 15:28 +0300 |
| Message-ID | <mailman.4951.1374409726.3114.python-list@python.org> |
| In reply to | #50914 |
21.07.13 14:29, Joshua Landau написав(ла):
> On 21 July 2013 08:44, Serhiy Storchaka <storchaka@gmail.com> wrote:
>> 20.07.13 20:03, Joshua Landau написав(ла):
>>
>>> Still, it seems to me that it should be optimizable for sensible
>>> builtin types such that .translate is significantly faster, as there's
>>> no theoretical extra work that .translate *has* to do that .replace
>>> does not, and .replace also has to rebuild the string a lot of times.
>>
>> You should analyze overall mapping and reorder items in right order (if it
>> possible), i.e. '&' should be replaced before '<' in html.escape. This extra
>> work is too large for most real input.
>
> I don't understand. What items are you reordering?
mapping.items(). We can implement s.translate({ord('<'): '<',
ord('&'): '&'}) as s.replace('&', '&').replace('<', '<'), but
not as s.replace('<', '<').replace('&', '&').
[toc] | [prev] | [next] | [standalone]
| From | Joshua Landau <joshua@landau.ws> |
|---|---|
| Date | 2013-07-21 13:49 +0100 |
| Message-ID | <mailman.4953.1374411017.3114.python-list@python.org> |
| In reply to | #50914 |
On 21 July 2013 13:28, Serhiy Storchaka <storchaka@gmail.com> wrote:
> 21.07.13 14:29, Joshua Landau написав(ла):
>
>> On 21 July 2013 08:44, Serhiy Storchaka <storchaka@gmail.com> wrote:
>>>
>>> 20.07.13 20:03, Joshua Landau написав(ла):
>>>
>>>> Still, it seems to me that it should be optimizable for sensible
>>>> builtin types such that .translate is significantly faster, as there's
>>>> no theoretical extra work that .translate *has* to do that .replace
>>>> does not, and .replace also has to rebuild the string a lot of times.
>>>
>>>
>>> You should analyze overall mapping and reorder items in right order (if
>>> it
>>> possible), i.e. '&' should be replaced before '<' in html.escape. This
>>> extra
>>> work is too large for most real input.
>>
>>
>> I don't understand. What items are you reordering?
>
>
> mapping.items(). We can implement s.translate({ord('<'): '<', ord('&'):
> '&'}) as s.replace('&', '&').replace('<', '<'), but not as
> s.replace('<', '<').replace('&', '&').
I see -- that won't always be the case though, as there can be "loops"
aka "ab" -> "ba".
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.python
csiph-web