Re: how to make this code faster

2005-10-12 Thread davbrow
It looks like you're using Numeric for your arrays, but you are then
pulling sin from the math module and calculating one point at a time.
Instead try using sin(whole array) where sin is a ufunc from the
Numeric module.  Also, it's usually not good practice to "import
Numeric as *".  Instead try import Numeric as N so it's clear which
functions you are using.

-- David

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


Re: print there!

2005-09-21 Thread davbrow
It's possible you will need to run python -u for this to behave as
expected.  Otherwise python may buffer the output until it sees a
newline so you only see the last result.

-- David

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


Re: Simple but fast 2D lib for drawing pixels

2006-10-01 Thread davbrow

Peter Mexbacher wrote:
> Hello,
>
> we want to teach absolute programming newbies
> a first language, so they can start programming
> simple scientific models.
>
> We thought Python would make a good choice for
> a first language; but where pretty stumped when
> we found out that there is no simple way to draw
> pixels to a screen. (This is needed for fractals,
> agent-based models etc -> like Conways Game of Life)
>
> Our requirements:
>
> -) easy to learn (newbs!)
> -) not too slow (after all, the models should simulate something)
> -) python :-)
>
> Any ideas?
>
> Best Regards,
> Peter

Did you look at the turtle module included in the standard
distribution?  It's very simple, made for beginners, and fast enough
for simple plots (just turn off the tracer).  If you intend to
introduce the class to GUI's at some point I believe turtle is built on
the Tkinter canvas widget, which may be suitable as well.

However, if you're teaching scientific programming to more technically
advanced users you might be better off using matplotlib/ipython.  That
will get you a matlab-like enviroment with many advanced capabilities.

-- David

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


Re: Creating a more random int?

2006-01-25 Thread davbrow
Well it IS unusual actually (~1/365.25).  Please tell them for me.

-- Dave

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


Re: Creating a more random int?

2006-01-25 Thread davbrow
Steven,

Have you considered you might want a less random distribution?  If you
just want to remove repeats so it 'seems' more random you could do that
(replace any repeat with another random value not equal to the last
value).  It likely will not be as uniformly random as the original
sequence but it will be 'smoother' in some definition that you might
prefer for your uses.  Be very careful though if you are going to use
it for technical work that requires a uniform  distribution in the
formal sense.

-- Dave

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