Fastest way to remove the first x characters from a very long string

2015-05-16 Thread bruceg113355
I have a string that contains 10 million characters. The string is formatted as: 001 : some hexadecimal text ... \n 002 : some hexadecimal text ... \n 003 : some hexadecimal text ... \n ... 010 : some hexadecimal text ... \n 011 : some hexadecimal text ... \n and I need the

Re: Fastest way to remove the first x characters from a very long string

2015-05-16 Thread bruceg113355
On Saturday, May 16, 2015 at 10:06:31 AM UTC-4, Stefan Ram wrote: bruceg113...@gmail.com writes: Your approach using .join is what I was looking for. I'd appreciate a report of your measurements. # Original Approach # - ss = ss.split(\n) ss1 = for sdata in ss: ss1 =

Re: Fastest way to remove the first x characters from a very long string

2015-05-16 Thread Chris Angelico
On Sun, May 17, 2015 at 2:22 AM, bruceg113...@gmail.com wrote: # Original Approach # - ss = ss.split(\n) ss1 = for sdata in ss: ss1 = ss1 + (sdata[OFFSET:] + \n) # Chris's Approach # lines = ss.split(\n) new_text = \n.join(line[8:] for line in

Re: Fastest way to remove the first x characters from a very long string

2015-05-16 Thread Irmen de Jong
On 16-5-2015 18:24, bruceg113...@gmail.com wrote: Data is coming from a wxPython TextCtrl widget. Hm, there should be a better source of the data before it ends up in the textctrl widget. The widget is displaying data received on a serial port for a user to analyze. If this is read from a

Re: Fastest way to remove the first x characters from a very long string

2015-05-16 Thread bruceg113355
On Saturday, May 16, 2015 at 12:59:19 PM UTC-4, Chris Angelico wrote: On Sun, May 17, 2015 at 2:22 AM, bruceg113...@gmail.com wrote: # Original Approach # - ss = ss.split(\n) ss1 = for sdata in ss: ss1 = ss1 + (sdata[OFFSET:] + \n) # Chris's Approach #

Re: Fastest way to remove the first x characters from a very long string

2015-05-16 Thread bruceg113355
On Saturday, May 16, 2015 at 9:46:17 AM UTC-4, Chris Angelico wrote: On Sat, May 16, 2015 at 11:28 PM, bruceg113...@gmail.com wrote: I have a string that contains 10 million characters. The string is formatted as: 001 : some hexadecimal text ... \n 002 : some hexadecimal text

Re: Fastest way to remove the first x characters from a very long string

2015-05-16 Thread Grant Edwards
On 2015-05-16, bruceg113...@gmail.com bruceg113...@gmail.com wrote: I have a string that contains 10 million characters. The string is formatted as: 001 : some hexadecimal text ... \n 002 : some hexadecimal text ... \n 003 : some hexadecimal text ... \n ... 010 : some

Re: Fastest way to remove the first x characters from a very long string

2015-05-16 Thread Joel Goldstick
On Sat, May 16, 2015 at 9:28 AM, bruceg113...@gmail.com wrote: I have a string that contains 10 million characters. The string is formatted as: 001 : some hexadecimal text ... \n 002 : some hexadecimal text ... \n 003 : some hexadecimal text ... \n ... 010 : some

Re: Fastest way to remove the first x characters from a very long string

2015-05-16 Thread Rustom Mody
On Saturday, May 16, 2015 at 8:30:02 PM UTC+5:30, Grant Edwards wrote: On 2015-05-16, bruceg113355 wrote: I have a string that contains 10 million characters. The string is formatted as: 001 : some hexadecimal text ... \n 002 : some hexadecimal text ... \n 003 : some

Re: Fastest way to remove the first x characters from a very long string

2015-05-16 Thread Chris Angelico
On Sat, May 16, 2015 at 11:28 PM, bruceg113...@gmail.com wrote: I have a string that contains 10 million characters. The string is formatted as: 001 : some hexadecimal text ... \n 002 : some hexadecimal text ... \n 003 : some hexadecimal text ... \n ... 010 : some

Re: Fastest way to remove the first x characters from a very long string

2015-05-16 Thread bruceg113355
On Saturday, May 16, 2015 at 11:13:45 AM UTC-4, Rustom Mody wrote: On Saturday, May 16, 2015 at 8:30:02 PM UTC+5:30, Grant Edwards wrote: On 2015-05-16, bruceg113355 wrote: I have a string that contains 10 million characters. The string is formatted as: 001 : some

Re: Fastest way to remove the first x characters from a very long string

2015-05-16 Thread Ian Kelly
On Sat, May 16, 2015 at 10:22 AM, bruceg113...@gmail.com wrote: # Chris's Approach # lines = ss.split(\n) new_text = \n.join(line[8:] for line in lines) Looks like the approach you have may be fast enough already, but I'd wager the generator expression could be replaced

Re: Fastest way to remove the first x characters from a very long string

2015-05-16 Thread Denis McMahon
On Sat, 16 May 2015 06:28:19 -0700, bruceg113355 wrote: I have a string that contains 10 million characters. The string is formatted as: 001 : some hexadecimal text ... \n 002 : some hexadecimal text ... \n 003 : some hexadecimal text ... \n ... 010 : some hexadecimal

Re: Fastest way to remove the first x characters from a very long string

2015-05-16 Thread Cameron Simpson
On 16May2015 10:35, bruceg113...@gmail.com bruceg113...@gmail.com wrote: On Saturday, May 16, 2015 at 12:59:19 PM UTC-4, Chris Angelico wrote: On Sun, May 17, 2015 at 2:22 AM, bruceg113...@gmail.com wrote: # Original Approach # - ss = ss.split(\n) ss1 = for sdata in ss: