Re: Thought of the day

2013-01-16 Thread John Ladasky
On Sunday, January 13, 2013 8:16:29 PM UTC-8, Steven D'Aprano wrote:
 A programmer had a problem, and thought Now he has I know, I'll solve 
 two it with threads! problems.

Very nice! :^)

This problem isn't exclusive to Python, however.  Other multi-threaded 
applications can produce jumbled output like this, even when the threads 
(processes?) are running on independent CPU's.

I use a very well-regarded application for molecular dynamics simulation: 
GROMACS, which I believe is written mostly in C (but there's even a little 
Fortran in it?  And supposedly, this is critical to performance?).  The GROMACS 
core program, mdrun, will grab as many CPUs as you allow it to use.  The output 
of mdrun looks exactly like your little quip as each CPU reports back that it 
has started its piece of mdrun.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thought of the day

2013-01-15 Thread Dave Angel
On 01/14/2013 09:18 AM, Chris Angelico wrote:
 On Tue, Jan 15, 2013 at 1:15 AM, Tim Chase
 python.l...@tim.thechases.com wrote:
 A newbie programmer had a problem and thought



 I'll solve it by posting on



 python-list@python.org and on Google Groups.



 And now we have the problem of two threads...
 And, when faced with problems of having two threads, the most obvious
 solution is to add sleep() calls, so it looks like the above... Am I
 dragging the analogy out too far?

 ChrisA

Naaah, too far would be trying to relate the GIL to KILL files.  For
example, I avoid the google groups double-post syndrome by killfiling
any message with google-groups in the To: or CC: fields.  596 messages
in six months.  I still get the second copy.




-- 

DaveA

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thought of the day

2013-01-15 Thread Antoine Pitrou
Steven D'Aprano steve+comp.lang.python at pearwood.info writes:
 
 A programmer had a problem, and thought Now he has I know, I'll solve 
 two it with threads! problems.


Host: Last week the Royal Festival Hall saw the first performance of a new
logfile by one of the world's leading modern programmers, Steven
Two threads D'Aprano. Mr D'Aprano.

D'Aprano: Hello.

Host: May I just sidetrack for one moment. This -- what shall I call it --
nickname of yours...

D'Aprano: Ah yes.

Host: Two threads. How did you come by it?

D'Aprano: Well, I don't use it myself, but some of my friends call me Two
Threads.

Host: And do you in fact have two threads?

D'Aprano: No, I've only got one. I've had one for some time, but a few
years ago I said I was thinking of spawning another, and since then some
people have called me Two Threads.

Host: In spite of the fact that you only have one.

D'Aprano: Yes.

Host: And are you still intending to spawn this second thread?

D'Aprano: (impatient) No!

Host: ...To bring you in line with your epithet?

D'Aprano: No.

Host: I see, I see. Well to return to your program.

D'Aprano: Ah yes.

Host: Did you write this logfile in the thread?

D'Aprano: (surprised) No!

Host: Have you written any of your recent files in this thread of yours?

D'Aprano: No, no, not at all. It's just an ordinary daemon thread.

Host: I see, I see. And you're thinking of spawning this second thread to
write in!

D'Aprano: No, no. Look. This thread business -- it doesn't really matter.
The threads aren't important. A few friends call me Two Threads and that's
all there is to it. I wish you'd ask me about the logfile. Everybody talks
about the threads. They've got it out of proportion -- I'm a programmer.
I'm going to get rid of the thread. I'm fed up with it!

Host: Then you'll be Steven No Threads D'Aprano, eh?


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thought of the day

2013-01-15 Thread Tim Golden
On 15/01/2013 16:48, Antoine Pitrou wrote:
 Steven D'Aprano steve+comp.lang.python at pearwood.info writes:

 A programmer had a problem, and thought Now he has I know, I'll solve 
 two it with threads! problems.
 
 
 Host: Last week the Royal Festival Hall saw the first performance of a new
 logfile by one of the world's leading modern programmers, Steven
 Two threads D'Aprano. Mr D'Aprano.

[... snip ...]

Brilliant, just brilliant.

TJG

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thought of the day

2013-01-15 Thread Chris Angelico
On Wed, Jan 16, 2013 at 3:48 AM, Antoine Pitrou solip...@pitrou.net wrote:
 D'Aprano: No, no. Look. This thread business -- it doesn't really matter.
 The threads aren't important. A few friends call me Two Threads and that's
 all there is to it. I wish you'd ask me about the logfile. Everybody talks
 about the threads. They've got it out of proportion -- I'm a programmer.
 I'm going to get rid of the thread. I'm fed up with it!

 Host: Then you'll be Steven No Threads D'Aprano, eh?

Close, Host. He'd be Steven No Marbles D'Aprano.

*whistles innocently*

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thought of the day

2013-01-15 Thread DJC

On 15/01/13 16:48, Antoine Pitrou wrote:

Steven D'Aprano steve+comp.lang.python at pearwood.info writes:


A programmer had a problem, and thought Now he has I know, I'll solve
two it with threads! problems.



Host: Last week the Royal Festival Hall saw the first performance of a new
logfile by one of the world's leading modern programmers, Steven
Two threads D'Aprano. Mr D'Aprano.

D'Aprano: Hello.

Host: May I just sidetrack for one moment. This -- what shall I call it --
nickname of yours...

D'Aprano: Ah yes.

Host: Two threads. How did you come by it?

[...]

Host: I see, I see. And you're thinking of spawning this second thread to
write in!

D'Aprano: No, no. Look. This thread business -- it doesn't really matter.
The threads aren't important. A few friends call me Two Threads and that's
all there is to it. I wish you'd ask me about the logfile. Everybody talks
about the threads. They've got it out of proportion -- I'm a programmer.
I'm going to get rid of the thread. I'm fed up with it!

Host: Then you'll be Steven No Threads D'Aprano, eh?



+ Applause

--
http://mail.python.org/mailman/listinfo/python-list


Re: Thought of the day

2013-01-14 Thread Dave Angel
On 01/13/2013 11:16 PM, Steven D'Aprano wrote:
 A programmer had a problem, and thought Now he has I know, I'll solve 
 two it with threads! problems.



++10

I've been thinking about threads lately, and have come to the tentative
conclusion that they're a solution which has outlived its usefulness for
99% of the use cases.  Much like the Windows 3.1 model of memory usage,
where all memory was shared, and apps promised not to step too hard on
each other.  Or the 640k is more memory than any application will ever
need notion.

When you multiprocess, everything is private except those things you
work at sharing.  When you multithread, everything is shared, and you
promise not to intentionally do anything too nasty with the ability.

-- 

DaveA

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thought of the day

2013-01-14 Thread alex23
On Jan 14, 2:16 pm, Steven D'Aprano steve
+comp.lang.pyt...@pearwood.info wrote:
 A programmer had a problem, and thought Now he has I know, I'll solve
 two it with threads! problems.

I laughed far far longer than I should have, cheers :)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thought of the day

2013-01-14 Thread Tim Chase

On 01/13/13 22:16, Steven D'Aprano wrote:

A programmer had a problem, and thought Now he has I know, I'll
solve two it with threads! problems.


A newbie programmer had a problem and thought I'll solve it by 
posting on python-list@python.org and on Google Groups.  And now we 
have the problem of two threads...


Intentionally-misinterpreting'ly yours,

-tkc



--
http://mail.python.org/mailman/listinfo/python-list


Re: Thought of the day

2013-01-14 Thread Chris Angelico
On Tue, Jan 15, 2013 at 1:15 AM, Tim Chase
python.l...@tim.thechases.com wrote:
 A newbie programmer had a problem and thought



 I'll solve it by posting on



 python-list@python.org and on Google Groups.



 And now we have the problem of two threads...

And, when faced with problems of having two threads, the most obvious
solution is to add sleep() calls, so it looks like the above... Am I
dragging the analogy out too far?

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thought of the day

2013-01-14 Thread Dan Sommers
On Mon, 14 Jan 2013 00:31:59 -0500, Dave Angel wrote:

 On 01/13/2013 11:16 PM, Steven D'Aprano wrote:
 A programmer had a problem, and thought Now he has I know, I'll solve
 two it with threads! problems.

 ++10

It took me a moment to figure it out, but in the end I smiled and I 
agree:  +1.

 I've been thinking about threads lately, and have come to the tentative
 conclusion that they're a solution which has outlived its usefulness for
 99% of the use cases.  Much like the Windows 3.1 model of memory usage,
 where all memory was shared, and apps promised not to step too hard on
 each other.  Or the 640k is more memory than any application will ever
 need notion.

With this, however, I don't agree.  If Python's GIL didn't interfere with 
the concurrency of threads, I can't think of a good reason to use 
multiple processes instead, except to use a tool that runs outside the 
Python virtual machine, or to provide more fault tolerance for long-
running server-like applications.  We're all adults here, and if the 
policy is to invoke the methods of objects as documented, then that 
policy extends to stepping on (or not stepping on) the memory of other 
threads, too.

The APIs for threads and processes is pretty much the same, so I suppose 
it doesn't matter much, either.  Use the right tool for the job.

Dan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thought of the day

2013-01-14 Thread Grant Edwards
On 2013-01-14, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:

 A programmer had a problem, and thought Now he has I know, I'll solve 
 two it with threads! problems.

:)

That took a few seconds -- must be the cold.

-- 
Grant Edwards   grant.b.edwardsYow! I hope I bought the
  at   right relish ... z
  gmail.com...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thought of the day

2013-01-14 Thread Dave Angel
On 01/14/2013 09:44 AM, Dan Sommers wrote:
 On Mon, 14 Jan 2013 00:31:59 -0500, Dave Angel wrote:

 On 01/13/2013 11:16 PM, Steven D'Aprano wrote:
 A programmer had a problem, and thought Now he has I know, I'll solve
 two it with threads! problems.
 ++10
 It took me a moment to figure it out, but in the end I smiled and I 
 agree:  +1.

 I've been thinking about threads lately, and have come to the tentative
 conclusion that they're a solution which has outlived its usefulness for
 99% of the use cases.  Much like the Windows 3.1 model of memory usage,
 where all memory was shared, and apps promised not to step too hard on
 each other.  Or the 640k is more memory than any application will ever
 need notion.
 With this, however, I don't agree.  If Python's GIL didn't interfere with 
 the concurrency of threads,

Better minds than mine have tried very hard to eliminate the GIL, so for
now I consider that a feature of Python.  If the GIL weren't needed for
the lowest levels of the interpreter, something else would be needed for
all the possible data structures that need atomic updates.  Hello
semaphores, mutexes, etc.  If threading were considered important in a
language, it'd have a way to declare an object sharable (default off),
and the low level code would go at full speed for any object not so
declared.  But the language would then provide guarantees for the
standard objects that are marked as sharable.  That's not current Python.

  I can't think of a good reason to use 
 multiple processes instead, except to use a tool that runs outside the 
 Python virtual machine, or to provide more fault tolerance for long-
 running server-like applications.  We're all adults here, and if the 
 policy is to invoke the methods of objects as documented, then that 
 policy extends to stepping on (or not stepping on) the memory of other 
 threads, too.

 The APIs for threads and processes is pretty much the same, so I suppose 
 it doesn't matter much, either.  Use the right tool for the job.

 Dan

For other languages, I've done extensive work on projects with heavy
multithreading, and getting it right is extremely difficult.  Another
way of putting it is that any non-trivial project with multithreading is
probably buggy. 



-- 

DaveA

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thought of the day

2013-01-14 Thread Demian Brecht
I love getting that what's up with this guy when I start chuckling so
hard that I nearly spit out my coffee first thing Monday morning.

Thank you sir, this has given my week a bright start :)

Demian Brecht
http://demianbrecht.github.com




On 2013-01-13 8:16 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:

A programmer had a problem, and thought Now he has I know, I'll solve
two it with threads! problems.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thought of the day

2013-01-14 Thread Demian Brecht
Š And I hope you don't mindŠ I may very well borrow this as my e-mail
sig. Comedic gold imo.

Demian Brecht
http://demianbrecht.github.com




On 2013-01-13 8:16 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:

A programmer had a problem, and thought Now he has I know, I'll solve
two it with threads! problems.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thought of the day

2013-01-14 Thread Michael Torrie
On 01/13/2013 09:16 PM, Steven D'Aprano wrote:
 A programmer had a problem, and thought Now he has I know, I'll solve 
 two it with threads! problems.

The same applies to regular expressions, which is actually what the
expression was first used with years ago.  Probably applies to just
about any technology.  Including Java.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thought of the day

2013-01-14 Thread John Gordon
In mailman.508.1358185089.2939.python-l...@python.org Michael Torrie 
torr...@gmail.com writes:

 On 01/13/2013 09:16 PM, Steven D'Aprano wrote:
  A programmer had a problem, and thought Now he has I know, I'll solve 
  two it with threads! problems.

 The same applies to regular expressions, which is actually what the
 expression was first used with years ago.  Probably applies to just
 about any technology.  Including Java.

Steven cleverly worded it in such a way as to apply directly to threads.
The sentences are jumbled and interleaved, as if they were the output of
two threads that are not synchronized.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, The Gashlycrumb Tinies

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thought of the day

2013-01-14 Thread Michael Torrie
On 01/14/2013 11:09 AM, John Gordon wrote:
 In mailman.508.1358185089.2939.python-l...@python.org Michael Torrie 
 torr...@gmail.com writes:
 
 On 01/13/2013 09:16 PM, Steven D'Aprano wrote:
 A programmer had a problem, and thought Now he has I know, I'll solve 
 two it with threads! problems.
 
 The same applies to regular expressions, which is actually what the
 expression was first used with years ago.  Probably applies to just
 about any technology.  Including Java.
 
 Steven cleverly worded it in such a way as to apply directly to threads.
 The sentences are jumbled and interleaved, as if they were the output of
 two threads that are not synchronized.

Very true!  Guess I was too distracted by Python's warts to notice. Haha.
-- 
http://mail.python.org/mailman/listinfo/python-list