Python Forum
One silly stripping func to complement the lib
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
One silly stripping func to complement the lib
#5
Interesting,
I should add that maketrans and translate can benefit form some examples in the documentation.
:)

(Oct-04-2020, 01:14 AM)scidam Wrote: str.translate is a bit faster...:
(scidev) dmitry@linux-mh4h:~/workspace/scipy> python -m timeit "'ajklbdkjsbc'.translate(str.maketrans('','','abc'))"
500000 loops, best of 5: 545 nsec per loop
(scidev) dmitry@linux-mh4h:~/workspace/scipy> python -m timeit "''.join([c for c in 'ajklbdkjsbc' if c not in 'abc'])"
500000 loops, best of 5: 572 nsec per loop
Reply


Messages In This Thread
RE: One silly stripping func to complement the lib - by voidptr - Oct-04-2020, 02:05 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020