Re: mutable ints: I think I have painted myself into a corner

2013-05-19 Thread Peter Otten
Cameron Simpson wrote:

> TL;DR: I think I want to modify an int value "in place".
> 
> Yesterday I was thinking about various "flag set" objects I have
> floating around which are essentially bare "object"s whose attributes
> I access, for example:
> 
>   flags = object()
>   flags.this = True
>   flags.that = False
> 
> and then elsewhere:
> 
>   if flags.that:
> do that ...
> 
> Nice and readable, but I thought to myself: so bulky!

Plus, it doesn't work:

>>> object().this = True
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'object' object has no attribute 'this'

> The use case for flags is essentially boolean/binary, and so a int
> accessed as a bitmask should be smaller.
> 
> So I pulled out my BitMask int subclass (which mostly transcribes
> the int as "A|B|C" for readability purposes, partly to dillute Nick
> Coglan's liking for bulky strings over compact ints on readability
> grounds:-), and gave the subclass attribute access.
> 
> This works just fine for querying the flags object, with code exactly
> like the "if" statement above.
> 
> But setting up a flags object? What I _want_ to write is code like this:
> 
>   Flags = BitMask('this', 'that')
> 
>   # set default state
>   flags = Flags()
>   flags.this = False
>   flags.that = True
>   ... iterate over some options ...: flags.this = True
> 
> and there's my problem. This would modify the int in place. There's
> no way to do that. For the base type (int) this makes perfect sense,
> as they're immutable.
> 
> Before I toss this approach and retreat to my former "object"
> technique, does anyone see a way forward to modify an int subclass
> instance in place? (That doesn't break math, preferably; I don't
> do arithmetic with these things but they are, after all, ints...)

No, but you could make

flags = Flags(this=False, that=True)

work.

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


Re: How to write fast into a file in python?

2013-05-19 Thread Chris Angelico
On Sun, May 19, 2013 at 3:31 PM, Carlos Nepomuceno
 wrote:
> Thanks Dan! I've never used CPython or PyPy. Will try them later.

CPython is the "classic" interpreter, written in C. It's the one
you'll get from the obvious download links on python.org.

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


RE: How to write fast into a file in python?

2013-05-19 Thread Carlos Nepomuceno
ooops! I meant to say Cython. nevermind...


> Date: Sun, 19 May 2013 19:21:54 +1000
> Subject: Re: How to write fast into a file in python?
> From: ros...@gmail.com
> To: python-list@python.org
>
> On Sun, May 19, 2013 at 3:31 PM, Carlos Nepomuceno
>  wrote:
>> Thanks Dan! I've never used CPython or PyPy. Will try them later.
>
> CPython is the "classic" interpreter, written in C. It's the one
> you'll get from the obvious download links on python.org.
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list   
>   
-- 
http://mail.python.org/mailman/listinfo/python-list


Harmonic distortion of a input signal

2013-05-19 Thread Anti Log
Hi,
I have a task to calculate total distortion of a harmonics, of a signal that i 
imported from oscilloscope as numpy array. I had no problem drawing its 
spectrum, and time domain graph, but cant seem to find any functions that 
calculate TDH.
Any help? 
Best regards
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Future standard GUI library

2013-05-19 Thread Kevin Walzer

On 5/18/13 11:01 PM, llanitedave wrote:

I'm curious about how commonly tkinter is actually used among Python app 
developers as compared to wx, Pyside, or PyQT.  I get the impression that more 
distributed apps are built with wxPython, at least, than tkinter.  My 
impression is far from actual knowledge, of course.



I have two commercial apps developed with Tkinter:

http://www.codebykevin.com/phynchronicity.html
http://www.codebykevin.com/quickwho.html

--Kevin

--
Kevin Walzer
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: What was the project that made you feel skilled in Python?

2013-05-19 Thread Roy Smith
In article ,
 Ned Batchelder  wrote:

> So here's a question for people who remember coming up from beginner: as 
> you moved from exercises like those in Learn Python the Hard Way, up to 
> your own self-guided work on small projects, what project were you 
> working on that made you feel independent and skilled?  What program 
> first felt like your own work rather than an exercise the teacher had 
> assigned?

IIRC, my first production python projects were a bunch of file parsers.  
We had a bunch of text file formats that we worked with often.  I wrote 
some state-machine based parsers which slurped them up and gave back the 
contents in some useful data structure.

Many of the files were big, so I added an option to write out a pickled 
version of the data.  The parsing code could then check to see if there 
was a pickle file that was newer than the text version and read that 
instead.  Big win for speed.

Then, of course, a bunch of utilities which used this data to do useful 
things.  I remember one of the utilities that turned out to be really 
popular was a smart data file differ.  You feed it two files and it 
would tell you how they differed (in a way that was more useful than a 
plain text-based diff).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Harmonic distortion of a input signal

2013-05-19 Thread Chris Angelico
On Sun, May 19, 2013 at 8:52 PM, Anti Log  wrote:
> total distortion of a harmonics

I selected this part of your post, right-clicked, and Chrome offered
to do a Google search for those words. And, surprise surprise, the
first hit is a page that appears to have the mathematics behind it.
Now, I don't know how much you trust Google and Wikipedia, but I'm
sure you can confirm the maths in some other way.

My guess is that there's no function in numpy to do what you're
asking... but it shouldn't be too hard to render the formula/e given
into Python code. Python's pretty expressive when it comes to algebra.
:)

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


Re: How to write fast into a file in python?

2013-05-19 Thread MRAB

On 19/05/2013 04:53, Carlos Nepomuceno wrote:



Date: Sat, 18 May 2013 22:41:32 -0400
From: da...@davea.name
To: python-list@python.org
Subject: Re: How to write fast into a file in python?

On 05/18/2013 01:00 PM, Carlos Nepomuceno wrote:

Python really writes '\n\r' on Windows. Just check the files.


That's backwards. '\r\n' on Windows, IF you omit the b in the mode when
creating the file.


Indeed! My mistake just made me find out that Acorn used that inversion on 
Acorn MOS.

According to this[1] (at page 449) the OSNEWL routine outputs '\n\r'.

What the hell those guys were thinking??? :p


Doing it that way saved a few bytes.

Code was something like this:

FFE3.OSASCI CMP #&0D
FFE5BNE OSWRCH
FFE7.OSNEWL LDA #&0A
FFE9JSR OSWRCH
FFECLDA #&0D
FFEE.OSWRCH ...

This means that the contents of the accumulator would always be
preserved by a call to OSASCI.


"OSNEWL
This call issues an LF CR (line feed, carriage return) to the currently selected
output stream. The routine is entered at &FFE7."

[1] http://regregex.bbcmicro.net/BPlusUserGuide-1.07.pdf




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


Python for philosophers

2013-05-19 Thread rusi
On May 17, 1:06 am, Citizen Kant  wrote:
> rusi said:
>
> > And let me suggest that you follow your own advise -- Can you say what
> > you have to say in 1/10th the number of words? Ok if not 1/10th then
> > 1/5th? 1-third?
>
> Thanks for the suggestion. I apologize for being that expansive; maybe you
> are right about this. In my world less use to be less. I'll try to review
> my doubts in order to express them in a much more concise format.
>
> Of course this is not trolling at all, and I'm intrigued by how fast
> someone can fall into that kind of conclusions...
>
> I'm pretty much interested in the topic, so I'll review the stuff.

You are doing well -- Glad to see that.
Except for the subject line. What's with the Fwd-loop?
Anyway I have attempted to correct it
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: any cherypy powred sites I can check out?

2013-05-19 Thread Walter Hurry
On Fri, 17 May 2013 11:48:19 +1000, Chris Angelico wrote:

> (Caveat: I am not a Catholic, so I haven't much of a clue as to how
> confession usually goes.)

Forgive OP Father, for he has sinned...

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


Re: Please help with Threading

2013-05-19 Thread Chris Angelico
On Mon, May 20, 2013 at 7:46 AM, Dennis Lee Bieber
 wrote:
> On Sun, 19 May 2013 10:38:14 +1000, Chris Angelico 
> declaimed the following in gmane.comp.python.general:
>> With interpreted code eg in CPython, it's easy to implement preemption
>> in the interpreter. I don't know how it's actually done, but one easy
>> implementation would be "every N bytecode instructions, context
>> switch". It's still done at a lower level than user code (N bytecode
>
> Which IS how the common Python interpreter does it -- barring the
> thread making some system call that triggers a preemption ahead of time
> (even time.sleep(0.0) triggers scheduling). Forget if the default is 20
> or 100 byte-code instructions -- as I recall, it DID change a few
> versions back.

Incidentally, is the context-switch check the same as the check for
interrupt signal raising KeyboardInterrupt? ISTR that was another
"every N instructions" check.

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


Re: Harmonic distortion of a input signal

2013-05-19 Thread killybeard91
How can i at least find a peek in FFT spectrum of a square wave ? 
>From there i could easily build formula. Sorry for bothering but i am new to 
>Python.

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


Re: Harmonic distortion of a input signal

2013-05-19 Thread Oscar Benjamin
On 19 May 2013 23:25,   wrote:
> How can i at least find a peek in FFT spectrum of a square wave ?
> From there i could easily build formula. Sorry for bothering but i am new to 
> Python.

Are you the same person who posted the original question?

You probably want to use numpy for this. I'm not sure if I understand
your question but here goes:

First import numpy (you may need to install this first):

>>> import numpy as np

Create a square wave signal:

>>> x = np.zeros(50)
>>> x[:25] = -1
>>> x[25:] = +1
>>> x
array([-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.,
   -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.,  1.,
1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,
1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.])

Compute the magnitude spectrum:

>>> spect = abs(np.fft.fft(x)[:25])
>>> spect
array([  0.,  31.85194222,   0.,  10.67342282,
 0.,   6.47213595,   0.,   4.69726931,
 0.,   3.73254943,   0.,   3.13762901,
 0.,   2.7436023 ,   0.,   2.47213595,
 0.,   2.28230601,   0.,   2.15105461,
 0.,   2.06487174,   0.,   2.01589594,   0.])

Find the index of the maximum element:

>>> np.argmax(spect)
1

So the peak is the lowest non-zero frequency component of the DFT. In
Hz this corresponds to a frequency of 1/T where T is the duration of
the signal.


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


Re: Harmonic distortion of a input signal

2013-05-19 Thread killybeard91
Yes, sorry logged from another account.
Would that work on a numpy array ? Because this signal was imported from 
oscilloscope as a numpy array.
Best regards,
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Harmonic distortion of a input signal

2013-05-19 Thread killybeard91
Got it working, thanks alot :)

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


Re: Harmonic distortion of a input signal

2013-05-19 Thread Terry Jan Reedy

On 5/19/2013 6:49 PM, Oscar Benjamin wrote:


import numpy as np


Create a square wave signal:


x = np.zeros(50)
x[:25] = -1
x[25:] = +1
x

array([-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.,
-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.,  1.,
 1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,
 1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.])

Compute the magnitude spectrum:


spect = abs(np.fft.fft(x)[:25])
spect

array([  0.,  31.85194222,   0.,  10.67342282,
  0.,   6.47213595,   0.,   4.69726931,
  0.,   3.73254943,   0.,   3.13762901,
  0.,   2.7436023 ,   0.,   2.47213595,
  0.,   2.28230601,   0.,   2.15105461,
  0.,   2.06487174,   0.,   2.01589594,   0.])

Find the index of the maximum element:


np.argmax(spect)

1

So the peak is the lowest non-zero frequency component of the DFT. In
Hz this corresponds to a frequency of 1/T where T is the duration of
the signal.


While you were answering a specific question, I think the above is a 
nice tutorial example, because it is more meaningful than arbitrary 
operations applied to random data.




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


Re: Harmonic distortion of a input signal

2013-05-19 Thread killybeard91
One more question. Function np.argmax returns max of non-complex numbers ? 
Because FFT array of my signal is complex.

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


Re: any cherypy powred sites I can check out?

2013-05-19 Thread Kevin Walzer

On 5/16/13 2:30 PM, Chris Angelico wrote:

On Fri, May 17, 2013 at 4:17 AM,   wrote:

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


You're firing off a bunch of minimal-content threads that ask other
people to do work for you. I recommend you put a bit more thought into
your posts, and show that you're willing to do a basic web search
before you just ask a question :)



He's also known on the Tcl newsgroup as Gavino; a Google search for 
"gavino tcl" will turn up some interesting hits. I also see that he's 
posting on comp.lang.perl as "Johannes Falcone." The common thread of 
his recent postings are subjects posed as questions, usually about 
various web frameworks, sometimes without even a single line in the 
message body. On the Tcl list it's AOLServer and NavServer. I'm not 
familiar with the Perl frameworks he's curious about.


--Kevin


--
Kevin Walzer
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Please help with Threading

2013-05-19 Thread Dave Angel

On 05/19/2013 05:46 PM, Dennis Lee Bieber wrote:

On Sun, 19 May 2013 10:38:14 +1000, Chris Angelico 
declaimed the following in gmane.comp.python.general:


On Sun, May 19, 2013 at 10:02 AM, Carlos Nepomuceno
 wrote:

I didn't know Python threads aren't preemptive. Seems to be something really 
old considering the state of the art on parallel execution on multi-cores.

What's the catch on making Python threads preemptive? Are there any ongoing 
projects to make that?






With interpreted code eg in CPython, it's easy to implement preemption
in the interpreter. I don't know how it's actually done, but one easy
implementation would be "every N bytecode instructions, context
switch". It's still done at a lower level than user code (N bytecode


Which IS how the common Python interpreter does it -- barring the
thread making some system call that triggers a preemption ahead of time
(even time.sleep(0.0) triggers scheduling). Forget if the default is 20
or 100 byte-code instructions -- as I recall, it DID change a few
versions back.

Part of the context switch is to transfer the GIL from the preempted
thread to the new thread.

So, overall, on a SINGLE CORE processor running multiple CPU bound
threads takes a bit longer just due to the overhead of thread swapping.

On a multi-core processor, the effect is the same, since -- even
though one may have a thread running on each core -- the GIL is only
assigned to one thread, and other threads get blocked when trying to
access runtime data structures. And you may have even more overhead from
processor cache misses if the a thread gets assigned to a different
core.

(yes -- I'm restating the same thing as I had just trimmed below
this point... but the target is really the OP, where repetition may be
helpful in understanding)



So what's the mapping between real (OS) threads, and the fake ones 
Python uses?  The OS keeps track of a separate stack and context for 
each thread it knows about;  are they one-to-one with the ones you're 
describing here?  If so, then any OS thread that gets scheduled will 
almost always find it can't get the GIL, and spend time thrashing.   But 
the change that CPython does intentionally would be equivalent to a 
sleep(0).


On the other hand, if these threads are distinct from the OS threads, is 
it done with some sort of thread pool, where CPython has its own stack, 
and doesn't really use the one managed by the OS?


Understand the only OS threading I really understand is the one in 
Windows (which I no longer use).  So assuming Linux has some form of 
lightweight threading, the distinction above may not map very well.




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


Re: Harmonic distortion of a input signal

2013-05-19 Thread Gregory Ewing

killybear...@gmail.com wrote:
One more question. Function np.argmax returns max of non-complex numbers ? 
Because FFT array of my signal is complex.


You'll want the magnitudes of the complex numbers.
Actually the squares of the magnitudes (assuming the
data from the oscilloscope represents voltages),
because you're after a ratio of powers.

--
Greg

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


Re: Harmonic distortion of a input signal

2013-05-19 Thread Dave Angel

On 05/19/2013 07:36 PM, killybear...@gmail.com wrote:

One more question. Function np.argmax returns max of non-complex numbers ?
Because FFT array of my signal is complex.



It'd be easier to track the thread if you actually replied to the 
message you're responding to, and also if you included some context. 
But I'll paste the latter in here:


Terry Reedy said:
> Compute the magnitude spectrum:

>>> spect = abs(np.fft.fft(x)[:25])
>>> spect
> array([  0.,  31.85194222,   0.,  10.67342282,
>  0.,   6.47213595,   0.,   4.69726931,
>  0.,   3.73254943,   0.,   3.13762901,
>  0.,   2.7436023 ,   0.,   2.47213595,
>  0.,   2.28230601,   0.,   2.15105461,
>  0.,   2.06487174,   0.,   2.01589594,
> 0.])

> Find the index of the maximum element:

>>> np.argmax(spect)
> 1


Notice that argmax's argument is the result of an abs() call.  It's got 
real numbers representing the magnitude of the various complex numbers.


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


Re: mutable ints: I think I have painted myself into a corner

2013-05-19 Thread Gregory Ewing

Cameron Simpson wrote:

It's an int _subclass_ so that it is no bigger than an int.


If you use __slots__ to eliminate the overhead of an
instance dict, you'll get an object consisting of a
header plus one reference, which is probably about the
size of an int. But you'll also need an int to put in
that slot, so the total size will be about twice that
of an int.

Another approach would be to subclass array.array and
give instances of it type integer and size 1. Together
with empty __slots__, it will probably be a bit bigger
than an int, but it might still be smaller than a
custom object plus an int.

If all of these are still too big, you might need to
find some way of packing multiple instances into a
single array.array.

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


Re: How to write fast into a file in python?

2013-05-19 Thread Tim Roberts
Carlos Nepomuceno  wrote:

>Python really writes '\n\r' on Windows. Just check the files.

It actually writes \r\n, but it's not Python that's doing it.  It's the C
runtime library.

And, of course, you can eliminate all of that by opening the file in binary
mode open(name,'wb').
-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to run a python script twice randomly in a day?

2013-05-19 Thread Avnesh Shakya
hi,
   How to run a python script twice randomly in a day? Actually I want to run 
my script randomly in a day and twice only. Please help me.. how is it possible.

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


Re: How to run a python script twice randomly in a day?

2013-05-19 Thread Jason Friedman
>How to run a python script twice randomly in a day? Actually I want to run 
> my script randomly in a day and twice only

I can think of two basic approaches.
One, use crontab or some other similar functionality to call it exactly twice.
Two, use crontab or some other similar functionality to call it every
minute, and add code to your script to execute exactly twice.
Which are you preferring?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to run a python script twice randomly in a day?

2013-05-19 Thread Cameron Simpson
On 19May2013 20:54, Avnesh Shakya  wrote:
|How to run a python script twice randomly in a day? Actually
| I want to run my script randomly in a day and twice only. Please
| help me.. how is it possible.

Do you mean "run twice a day, each at random times"?

If so, do the obvious: at midnight, pick two random times. Sleep
until the first time, run the script, sleep until the second time,
run the script.

There are various ways to do the sleeping and midnight bits; they're
up to you.

Enjoy,
-- 
Cameron Simpson 

The ZZR-1100 is not the bike for me, but the day they invent "nerf" roads
and ban radars I'll be the first in line..AMCN
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Future standard GUI library

2013-05-19 Thread Vito De Tullio
Terry Jan Reedy wrote:

>> Do you think tkinter is going to be the standard python built-in gui
>> solution as long as python exists?
> 
> AT the moment, there is nothing really comparable that is a realistic
> candidate to replace tkinter.

FLTK? (http://www.fltk.org/index.php)

-- 
ZeD

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


Re: mutable ints: I think I have painted myself into a corner

2013-05-19 Thread Cameron Simpson
On 19May2013 09:01, Peter Otten <__pete...@web.de> wrote:
| Cameron Simpson wrote:
| 
| > TL;DR: I think I want to modify an int value "in place".
| > 
| > Yesterday I was thinking about various "flag set" objects I have
| > floating around which are essentially bare "object"s whose attributes
| > I access, for example:
| > 
| >   flags = object()
| >   flags.this = True
| >   flags.that = False
| > 
| > and then elsewhere:
| > 
| >   if flags.that:
| > do that ...
| > 
| > Nice and readable, but I thought to myself: so bulky!
| 
| Plus, it doesn't work:

Yeah, sorry. My "old" code was a trite subclass of object.
The new broken code is a subclass of int.

| > But setting up a flags object? What I _want_ to write is code like this:
| > 
| >   Flags = BitMask('this', 'that')
| > 
| >   # set default state
| >   flags = Flags()
| >   flags.this = False
| >   flags.that = True
| >   ... iterate over some options ...: flags.this = True
| > 
| > and there's my problem. This would modify the int in place. There's
| > no way to do that. For the base type (int) this makes perfect sense,
| > as they're immutable.
| > 
| > Before I toss this approach and retreat to my former "object"
| > technique, does anyone see a way forward to modify an int subclass
| > instance in place? (That doesn't break math, preferably; I don't
| > do arithmetic with these things but they are, after all, ints...)
| 
| No, but you could make
| 
| flags = Flags(this=False, that=True)

Yes, that is true. Flags would need to be a factory function computing
the corresponding bitmask value and then returning my new int, but
it would work. It still wouldn't let me go the whole way of modifying
the flags after instantiation.

Cheers,
-- 
Cameron Simpson 

Carpe Daemon - Seize the Background Process
- Paul Tomblin 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: mutable ints: I think I have painted myself into a corner

2013-05-19 Thread Cameron Simpson
On 20May2013 13:23, Greg Ewing  wrote:
| Cameron Simpson wrote:
| >It's an int _subclass_ so that it is no bigger than an int.
| 
| If you use __slots__ to eliminate the overhead of an
| instance dict, you'll get an object consisting of a
| header plus one reference, which is probably about the
| size of an int. But you'll also need an int to put in
| that slot, so the total size will be about twice that
| of an int.

Yeah, I was thinking I'd need to go that way. Thanks for the
suggestion.

| Another approach would be to subclass array.array and
| give instances of it type integer and size 1. Together
| with empty __slots__, it will probably be a bit bigger
| than an int, but it might still be smaller than a
| custom object plus an int.

Really? Interesting. I thinik it crosses my "too baroque" threshold,
but maybe not:-)

| If all of these are still too big, you might need to
| find some way of packing multiple instances into a
| single array.array.

Space isn't that real an issue at present; I'll keep that kind of
approach in mind if it comes up. This really came up because I was
feeling that the obvious object-with-boolean-attributes was terrbily
wasteful for something that can be inplemented with a single int,
in principle.

Cheers,
-- 
Cameron Simpson 

>>>How do you blip the throttle and wave? Do you blip it real high, then wave
>>>before the revs drop back?
>>Blip = right hand; Wave = left hand.  Do both simultaneously.  QED.
>Doesnt this make the bike lurch forward thru the intersection?
Not if the disk lock is in place...
- Dean Woodward 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please help with Threading

2013-05-19 Thread Fábio Santos
On 18 May 2013 20:33, "Dennis Lee Bieber"  wrote:
> Python threads work fine if the threads either rely on intelligent
> DLLs for number crunching (instead of doing nested Python loops to
> process a numeric array you pass it to something like NumPy which
> releases the GIL while crunching a copy of the array) or they do lots of
> I/O and have to wait for I/O devices (while one thread is waiting for
> the write/read operation to complete, another thread can do some number
> crunching).

Has nobody thought of a context manager to allow a part of your code to
free up the GIL? I think the GIL is not inherently bad, but if it poses a
problem at times, there should be a way to get it out of your... Way.
-- 
http://mail.python.org/mailman/listinfo/python-list