Re: When are immutable tuples *essential*? Why can't you just use lists *everywhere* instead?

2007-04-20 Thread garrickp
On Apr 20, 4:37 pm, John Machin <[EMAIL PROTECTED]> wrote: > One inessential but very useful thing about tuples when you have a lot > of them is that they are allocated the minimum possible amount of > memory. OTOH lists are created with some slack so that appending etc > can avoid taking quadratic

Re: catching exceptions from an except: block

2007-03-07 Thread garrickp
On Mar 7, 3:04 pm, [EMAIL PROTECTED] wrote: > On Mar 7, 2:48 pm, "Arnaud Delobelle" <[EMAIL PROTECTED]> wrote: > > > > > > > I'm not really thinking about this situation so let me clarify. Here > > is a simple concrete example, taking the following for the functions > > a,b,c I mention in my origin

Re: catching exceptions from an except: block

2007-03-07 Thread garrickp
On Mar 7, 2:48 pm, "Arnaud Delobelle" <[EMAIL PROTECTED]> wrote: > > I'm not really thinking about this situation so let me clarify. Here > is a simple concrete example, taking the following for the functions > a,b,c I mention in my original post. > - a=int > - b=float > - c=complex > - x i

Re: Regex Speed

2007-02-23 Thread garrickp
On Feb 21, 10:34 am, [EMAIL PROTECTED] wrote: > On Feb 20, 6:14 pm, Pop User <[EMAIL PROTECTED]> wrote: > >http://swtch.com/~rsc/regexp/regexp1.html Going back a bit on a tangent, the author of this citation states that any regex can be expressed as a DFA machine. However, while investigating thi

Re: Creating a daemon process in Python

2007-02-21 Thread garrickp
On Feb 21, 3:34 pm, Benjamin Niemann <[EMAIL PROTECTED]> wrote: > That's not a daemon process (which are used to execute 'background services' > in UNIX environments). I had not tested this by running the script directly, and in writing a response, I found out that the entire interpreter closed wh

Re: Creating a daemon process in Python

2007-02-21 Thread garrickp
On Feb 21, 9:33 am, Eirikur Hallgrimsson <[EMAIL PROTECTED]> wrote: > Sakagami Hiroki wrote: > > What is the easiest way to create a daemon process in Python? I've found it even easier to use the built in threading modules: import time t1 = time.time() print "t_poc.py called at", t1 import thre

Re: Regex Speed

2007-02-21 Thread garrickp
On Feb 20, 6:14 pm, Pop User <[EMAIL PROTECTED]> wrote: > Its very hard to beat grep depending on the nature of the regex you are > searching using. The regex engines in python/perl/php/ruby have traded > the speed of grep/awk for the ability to do more complex searches. > > http://swtch.com/~rsc/

Re: Regex Speed

2007-02-20 Thread garrickp
On Feb 20, 4:15 pm, "John Machin" <[EMAIL PROTECTED]> wrote: > What is an "exclusionary set"? It would help enormously if you were to > tell us what the regex actually is. Feel free to obfuscate any > proprietary constant strings, of course. My apologies. I don't have specifics right now, but it'

Regex Speed

2007-02-20 Thread garrickp
While creating a log parser for fairly large logs, we have run into an issue where the time to process was relatively unacceptable (upwards of 5 minutes for 1-2 million lines of logs). In contrast, using the Linux tool grep would complete the same search in a matter of seconds. The search we used

Re: output to console and to multiple files

2007-02-16 Thread garrickp
On Feb 16, 3:28 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > > That's ok inside the same process, but the OP needs to use it "from a > subprocess or spawn". > You have to use something like tee, working with real file handles. > I'm not particularly familiar with this, but it seems to me

Re: multi processes

2007-02-14 Thread garrickp
On Feb 14, 7:53 am, "amadain" <[EMAIL PROTECTED]> wrote: > Hi > Heres a poser. I want to start a program 4 times at exactly the same > time (emulating 4 separate users starting up the same program). I am > using pexpect to run the program from 4 separate locations accross the > network. How do I st

Re: threading and multicores, pros and cons

2007-02-14 Thread garrickp
On Feb 13, 9:07 pm, Maric Michaud <[EMAIL PROTECTED]> wrote: > I've heard of a bunch of arguments to defend python's choice of GIL, but I'm > not quite sure of their technical background, nor what is really important > and what is not. These discussions often end in a prudent "python has made a > c

Re: division by 7 efficiently ???

2007-02-06 Thread garrickp
On Feb 6, 4:54 pm, "John Machin" <[EMAIL PROTECTED]> wrote: > Recursive? Bzzzt! I woudl be happy to hear your alternative, which doesn't depend on language specific tricks. Thus far, all you have suggested is using an alternative form of the division function, which I would consider to be outside

Re: division by 7 efficiently ???

2007-02-06 Thread garrickp
On Feb 1, 8:25 pm, "Krypto" <[EMAIL PROTECTED]> wrote: > The correct answer as told to me by a person is > (N>>3) + ((N-7*(N>>3))>>3) > The above term always gives division by 7 Does anybody else notice that this breaks the spirit of the problem (regardless of it's accuracy)? 'N-7' uses the subtra