Message66416
| Author | belopolsky |
|---|---|
| Recipients | belopolsky, benjamin.peterson, donlorenzo, rsc, zanella |
| Date | 2008-05-08.14:08:15 |
| SpamBayes Score | 0.0027484938 |
| Marked as misclassified | No |
| Message-id | <1210255709.4.0.944861854389.issue2650@psf.upfronthosting.co.za> |
| In-reply-to |
| Content | |
|---|---|
Lorenz's patch uses a set, not a list for special characters. Set
lookup is as fast as dict lookup, but a set takes less memory because it
does not have to store dummy values. More importantly, use of frozenset
instead of dict makes the code clearer. On the other hand, I would
simply use a string. For a dozen entries, hash lookup does not buy you
much.
Another nit: why use "\\%c" % (c) instead of obvious "\\" + c?
Finally, you can eliminate use of index and a temporary list altogether
by using a generator expression:
''.join(("\\" + c if c in _special else '\\000' if c == "\000" else c),
for c in pattern) |
|
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2008-05-08 14:08:30 | belopolsky | set | spambayes_score: 0.00274849 -> 0.0027484938 recipients: + belopolsky, rsc, benjamin.peterson, zanella, donlorenzo |
| 2008-05-08 14:08:29 | belopolsky | set | spambayes_score: 0.00274849 -> 0.00274849 messageid: <1210255709.4.0.944861854389.issue2650@psf.upfronthosting.co.za> |
| 2008-05-08 14:08:28 | belopolsky | link | issue2650 messages |
| 2008-05-08 14:08:25 | belopolsky | create | |