Re: [Tutor] Question about O(N**2)

2014-05-03 Thread Steven D'Aprano
On Sat, May 03, 2014 at 03:59:40PM -0700, Danny Yoo wrote: > Following up on this. Let's make sure that we're talking about the same > thing. > > > The assertion is that the following: > > fullPath += [...] > > where fullPath is a list of strings, exhibits O(n^2) time. I don't > think th

Re: [Tutor] Logical error?

2014-05-03 Thread Danny Yoo
> > for encoding in ('utf-8', 'utf-16', 'utf-32'): > for i in range(0x11): > aChar = unichr(i) > try: > someBytes = aChar.encode(encoding) > if '\n' in someBytes: > print("%r contains a newlin

Re: [Tutor] Logical error?

2014-05-03 Thread Danny Yoo
>> A small note about performance here. If your log files are very large >> (say, hundreds of thousands or millions of lines) you will find that >> this part is *horribly horrible slow*. There's two problems, a minor and >> a major one. > > Ah, actually I was mistaken about that. I forgot that for

Re: [Tutor] Logical error?

2014-05-03 Thread Steven D'Aprano
On Sat, May 03, 2014 at 11:53:27AM +1000, Steven D'Aprano wrote: > [...] > > fullPath = [] # declare (initially empty) lists > > truncPath = [] > > > > with codecs.open('/var/log/rsyncd.log', 'r') as rsyncd_log: > > for line in rsyncd_log.readlines(): > > fullPath += [line.decode('u

Re: [Tutor] Question about O(N**2)

2014-05-03 Thread Danny Yoo
Following up on this. Let's make sure that we're talking about the same thing. The assertion is that the following: fullPath += [...] where fullPath is a list of strings, exhibits O(n^2) time. I don't think this is true. Semantically, the statement above should be equivalent to: full

[Tutor] Question about O(N**2)

2014-05-03 Thread David Rock
The the "Logical Error" question, this was brought up: The big problem is this:

Re: [Tutor] Logical error?

2014-05-03 Thread Bob Williams
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Steven, On 03/05/14 02:53, Steven D'Aprano wrote: > Hi Bob, and welcome! > > My responses interleaved with yours, below. > > On Fri, May 02, 2014 at 11:19:26PM +0100, Bob Williams wrote: >> -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 >> >> Hi,