Re: Function to show time to execute another function

2015-06-07 Thread Mark Lawrence
On 07/06/2015 07:39, Cecil Westerhof wrote: Sometimes I just want to know how much time a function takes, but at the same time I also want the result of the function. For this I wrote the following function: def time_test(function, *args): startTime = time.time() results

Re: Find in ipython3

2015-06-07 Thread Cameron Simpson
On 07Jun2015 08:20, Cecil Westerhof wrote: There is no gain to get in standard Python? By switching from fnmatch to re I got almost a speed gain of two. So I was wondering if I could do more. Maybe write a few versions: one really dumb using filename == matchstring (like -name foo), one using

Re: Ah Python, you have spoiled me for all other languages

2015-06-07 Thread Thomas 'PointedEars' Lahn
Ned Batchelder wrote: > On Saturday, May 23, 2015 at 9:01:29 AM UTC-4, Steven D'Aprano wrote: >> On Sat, 23 May 2015 10:33 pm, Thomas 'PointedEars' Lahn wrote: >> > If only characters were represented as sequences UTF-16 code units in >> > ECMAScript implementations like JavaScript, there would no

Re: Embedded Python and C Callback functions

2015-06-07 Thread doc . mefisto
No, myclass is not null. I think my style of passing arguments is wrong. -- https://mail.python.org/mailman/listinfo/python-list

Re: Function to show time to execute another function

2015-06-07 Thread Cecil Westerhof
On Sunday 7 Jun 2015 09:39 CEST, Mark Lawrence wrote: > On 07/06/2015 07:39, Cecil Westerhof wrote: >> Sometimes I just want to know how much time a function takes, but >> at the same time I also want the result of the function. For this I >> wrote the following function: def time_test(function,

Re: Embedded Python and C Callback functions

2015-06-07 Thread doc . mefisto
And I can't use Cython, because I have C++ module, and I have to use it. -- https://mail.python.org/mailman/listinfo/python-list

Re: Function to show time to execute another function

2015-06-07 Thread Luca Menegotto
Il 07/06/2015 10:22, Cecil Westerhof ha scritto: > That only times the function. I explicitly mentioned I want both the > needed time AND the output. > > Sadly the quality of the answers on this list is going down First of all, thank God it's a newsgroup, not a list. Second, often the qualit

Re: Embedded Python and C Callback functions

2015-06-07 Thread doc . mefisto
I'm trying to debug and find my error. It goes wrong when: PyObject *v; v = va_arg(*p_va, PyObject *); if (v != NULL) { if (*(*p_format - 1) != 'N') Py_INCREF(v); } it tries to PyINCREF to my passed callback. -- https://mail

Re: Function to show time to execute another function

2015-06-07 Thread Steven D'Aprano
On Sun, 7 Jun 2015 04:39 pm, Cecil Westerhof wrote: > Sometimes I just want to know how much time a function takes, but at > the same time I also want the result of the function. For this I wrote > the following function: > def time_test(function, *args): > startTime = time.time() >

Re: Find in ipython3

2015-06-07 Thread Laura Creighton
In a message of Sun, 07 Jun 2015 08:20:46 +0200, Cecil Westerhof writes: >> You may get faster results if you use Matthew Barnett's replacement >> for re here: https://pypi.python.org/pypi/regex >> >> You will get faster results if you build your IPython shell to use >> PyPy, but I would still be v

Re: Function to show time to execute another function

2015-06-07 Thread Luca Menegotto
Il 07/06/2015 11:28, Steven D'Aprano ha scritto: But if your function takes less than, say, 1 millisecond, then your timing results are probably just meaningless random numbers, affected more by the other ten thousand processes running on your computer than by the Python code itself. That's a

Re: Embedded Python and C Callback functions

2015-06-07 Thread Laura Creighton
In a message of Sun, 07 Jun 2015 01:56:47 -0700, [email protected] writes: >And I can't use Cython, because I have C++ module, and I have to use it. >-- >https://mail.python.org/mailman/listinfo/python-list Are you using Boost? http://www.boost.org/doc/libs/1_58_0/libs/python/doc/ It handles

Re: Embedded Python and C Callback functions

2015-06-07 Thread doc . mefisto
> >And I can't use Cython, because I have C++ module, and I have to use it. > >-- > >https://mail.python.org/mailman/listinfo/python-list > > Are you using Boost? > http://www.boost.org/doc/libs/1_58_0/libs/python/doc/ > > It handles lots of the setup for you. > > Laura No, I'm not using Boost

Re: Function to show time to execute another function

2015-06-07 Thread Steven D'Aprano
On Sun, 7 Jun 2015 04:39 pm, Cecil Westerhof wrote: > Sometimes I just want to know how much time a function takes, but at > the same time I also want the result of the function. For this I wrote > the following function: > def time_test(function, *args): > startTime = time.time() >

Re: Function to show time to execute another function

2015-06-07 Thread Cecil Westerhof
On Sunday 7 Jun 2015 08:39 CEST, Cecil Westerhof wrote: > Sometimes I just want to know how much time a function takes, but at > the same time I also want the result of the function. For this I > wrote the following function: def time_test(function, *args): > startTime = time.time() results = fun

Re: Function to show time to execute another function

2015-06-07 Thread Mark Lawrence
On 07/06/2015 09:22, Cecil Westerhof wrote: On Sunday 7 Jun 2015 09:39 CEST, Mark Lawrence wrote: On 07/06/2015 07:39, Cecil Westerhof wrote: Sometimes I just want to know how much time a function takes, but at the same time I also want the result of the function. For this I wrote the followi

Re: Find in ipython3

2015-06-07 Thread Peter Otten
Cecil Westerhof wrote: > On Saturday 6 Jun 2015 13:07 CEST, Laura Creighton wrote: > >> The !find version is C code optimised to do one thing, find files in >> your directory structure, which happens to be what you want to do. >> General regular expression matching is harder. >> >> Carl Friedric

Re: Testing random

2015-06-07 Thread Thomas 'PointedEars' Lahn
Cecil Westerhof wrote: > I wrote a very simple function to test random: > def test_random(length, multiplier = 1): > number_list = length * [0] > for i in range(length * multiplier): > number_list[random.randint(0, length - 1)] += 1 > minimum = min(numbe

Re: Testing random

2015-06-07 Thread Jonas Wielicki
On 07.06.2015 08:27, Cecil Westerhof wrote: > I wrote a very simple function to test random: > def test_random(length, multiplier = 1): > number_list = length * [0] > for i in range(length * multiplier): > number_list[random.randint(0, length - 1)] += 1 >

Re: Function to show time to execute another function

2015-06-07 Thread Tim Golden
On 07/06/2015 11:16, Mark Lawrence wrote: On 07/06/2015 09:22, Cecil Westerhof wrote: That only times the function. I explicitly mentioned I want both the needed time AND the output. Sadly the quality of the answers on this list is going down. Here I get an alternative that does only half what

[OT] Re: Function to show time to execute another function

2015-06-07 Thread Marko Rauhamaa
Mark Lawrence : > Get your cheque book and go for paid support. Are checks still in use in Britain? I thought only Americans still did that. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: [OT] Re: Function to show time to execute another function

2015-06-07 Thread Mark Lawrence
On 07/06/2015 12:02, Marko Rauhamaa wrote: Mark Lawrence : Get your cheque book and go for paid support. Are checks still in use in Britain? I thought only Americans still did that. Marko Cheques are still in use in Britain. There was a move a year or so ago to get rid of them but too m

Is it a newsgroup or a list?

2015-06-07 Thread random832
On Sun, Jun 7, 2015, at 05:06, Luca Menegotto wrote: > Il 07/06/2015 10:22, Cecil Westerhof ha scritto: > > That only times the function. I explicitly mentioned I want both the > > needed time AND the output. > > > > Sadly the quality of the answers on this list is going down > > First of

Re: Function to show time to execute another function

2015-06-07 Thread Steven D'Aprano
On Sun, 7 Jun 2015 08:16 pm, Mark Lawrence wrote: > I suggest that you stop asking so many question here. Get your cheque > book and go for paid support. Mark, that remark is uncalled for and completely out of line. Cecil is perfectly entitled to ask questions here, and you are entitled to igno

Re: Ah Python, you have spoiled me for all other languages

2015-06-07 Thread Steven D'Aprano
On Sun, 7 Jun 2015 06:21 pm, Thomas 'PointedEars' Lahn wrote: > Ned Batchelder wrote: > >> On Saturday, May 23, 2015 at 9:01:29 AM UTC-4, Steven D'Aprano wrote: >>> On Sat, 23 May 2015 10:33 pm, Thomas 'PointedEars' Lahn wrote: >>> > If only characters were represented as sequences UTF-16 code un

Re: Is it a newsgroup or a list?

2015-06-07 Thread Steven D'Aprano
On Sun, 7 Jun 2015 09:20 pm, [email protected] wrote: > On Sun, Jun 7, 2015, at 05:06, Luca Menegotto wrote: >> Il 07/06/2015 10:22, Cecil Westerhof ha scritto: >> > That only times the function. I explicitly mentioned I want both the >> > needed time AND the output. >> > >> > Sadly the qu

Re: Is it a newsgroup or a list?

2015-06-07 Thread Zachary Ware
On Sunday, June 7, 2015, wrote: > On Sun, Jun 7, 2015, at 05:06, Luca Menegotto wrote: > > Il 07/06/2015 10:22, Cecil Westerhof ha scritto: > > > That only times the function. I explicitly mentioned I want both the > > > needed time AND the output. > > > > > > Sadly the quality of the answers

Re: Testing random

2015-06-07 Thread Chris Angelico
On Sun, Jun 7, 2015 at 8:40 PM, Thomas 'PointedEars' Lahn wrote: > Cecil Westerhof wrote: > >> I wrote a very simple function to test random: >> def test_random(length, multiplier = 1): >> number_list = length * [0] >> for i in range(length * multiplier): >> num

Re: Ah Python, you have spoiled me for all other languages

2015-06-07 Thread Chris Angelico
On Sun, Jun 7, 2015 at 9:42 PM, Steven D'Aprano wrote: > My opinion is that a programming language like Python or ECMAScript should > operate on *code points*. If we want to call them "characters" informally, > that should be allowed, but whenever there is ambiguity we should remember > we're deal

Re: Function to show time to execute another function

2015-06-07 Thread Cecil Westerhof
On Sunday 7 Jun 2015 11:06 CEST, Luca Menegotto wrote: > Il 07/06/2015 10:22, Cecil Westerhof ha scritto: >> That only times the function. I explicitly mentioned I want both >> the needed time AND the output. >> >> Sadly the quality of the answers on this list is going down > > First of all,

Re: Function to show time to execute another function

2015-06-07 Thread Cecil Westerhof
On Sunday 7 Jun 2015 11:28 CEST, Steven D'Aprano wrote: > On Sun, 7 Jun 2015 04:39 pm, Cecil Westerhof wrote: > >> Sometimes I just want to know how much time a function takes, but >> at the same time I also want the result of the function. For this I >> wrote the following function: def time_tes

Re: Function to show time to execute another function

2015-06-07 Thread Cecil Westerhof
On Sunday 7 Jun 2015 11:51 CEST, Steven D'Aprano wrote: > On Sun, 7 Jun 2015 04:39 pm, Cecil Westerhof wrote: > >> Sometimes I just want to know how much time a function takes, but >> at the same time I also want the result of the function. For this I >> wrote the following function: def time_tes

Re: Function to show time to execute another function

2015-06-07 Thread Cecil Westerhof
On Sunday 7 Jun 2015 12:16 CEST, Mark Lawrence wrote: > I suggest that you stop asking so many question here. Get your > cheque book and go for paid support. First of all: it was not a question: I shared something I thought was useful. You can disagree about it being useful, but there is in my o

Re: Testing random

2015-06-07 Thread Steven D'Aprano
On Sun, 7 Jun 2015 04:27 pm, Cecil Westerhof wrote: > I wrote a very simple function to test random: > def test_random(length, multiplier = 1): > number_list = length * [0] > for i in range(length * multiplier): > number_list[random.randint(0, length - 1)] += 1

Re: Testing random

2015-06-07 Thread Christian Gollwitzer
Am 07.06.15 um 08:27 schrieb Cecil Westerhof: I wrote a very simple function to test random: def test_random(length, multiplier = 1): number_list = length * [0] for i in range(length * multiplier): number_list[random.randint(0, length - 1)] += 1 mi

Re: Function to show time to execute another function

2015-06-07 Thread Cecil Westerhof
On Sunday 7 Jun 2015 13:05 CEST, Tim Golden wrote: > On 07/06/2015 11:16, Mark Lawrence wrote: >> On 07/06/2015 09:22, Cecil Westerhof wrote: >>> That only times the function. I explicitly mentioned I want both >>> the needed time AND the output. >>> >>> Sadly the quality of the answers on this l

Re: Find in ipython3

2015-06-07 Thread Laura Creighton
In a message of Sun, 07 Jun 2015 12:27:05 +0200, Peter Otten writes: >> There is no gain to get in standard Python? By switching from fnmatch >> to re I got almost a speed gain of two. So I was wondering if I could >> do more. > >Just wait for Python 3.5. The switch from os.listdir() to the (new)

Re: Function to show time to execute another function

2015-06-07 Thread Laura Creighton
In a message of Sun, 07 Jun 2015 11:16:30 +0100, Mark Lawrence writes: >I suggest that you stop asking so many question here. Get your cheque >book and go for paid support. Knock this off, please. Some of us dearly like to teach people who want to explore and learn things. Laura -- https://m

Re: Testing random

2015-06-07 Thread Steven D'Aprano
On Sun, 7 Jun 2015 10:52 pm, Steven D'Aprano wrote: > The median is unchanged, the mean shifts slightly higher, and the standard > deviation increases. But as you can see, these are not particularly > powerful tests of randomness: only the mode shows an obvious deviation > from uniformity. Oh, I

Re: Is it a newsgroup or a list?

2015-06-07 Thread Chris Warrick
On Sun, Jun 7, 2015 at 1:45 PM, Steven D'Aprano wrote: > As far as I know, python-list a.k.a. comp.lang.python is the only one of the > Python mailing lists with an official newsgroup mirror. comp.lang.python.announce also exists. Sent via mailing list. -- Chris Warrick

Re: Find in ipython3

2015-06-07 Thread Steven D'Aprano
On Sun, 7 Jun 2015 07:33 pm, Laura Creighton wrote: > In a message of Sun, 07 Jun 2015 08:20:46 +0200, Cecil Westerhof writes: >>> You may get faster results if you use Matthew Barnett's replacement >>> for re here: https://pypi.python.org/pypi/regex >>> >>> You will get faster results if you buil

Re: Ah Python, you have spoiled me for all other languages

2015-06-07 Thread Steven D'Aprano
On Sun, 7 Jun 2015 10:08 pm, Chris Angelico wrote: > On Sun, Jun 7, 2015 at 9:42 PM, Steven D'Aprano > wrote: >> My opinion is that a programming language like Python or ECMAScript >> should operate on *code points*. If we want to call them "characters" >> informally, that should be allowed, but

Re: Function to show time to execute another function

2015-06-07 Thread Cecil Westerhof
On Sunday 7 Jun 2015 11:28 CEST, Steven D'Aprano wrote: > Here is a simple example: > > http://code.activestate.com/recipes/577896-benchmark-code-with-the-with-statement/ I use that now in my function: #--- def time_test(function

Re: Testing random

2015-06-07 Thread Peter Otten
Steven D'Aprano wrote: >> I wrote a very simple function to test random: >> def test_random(length, multiplier = 1): >> number_list = length * [0] >> for i in range(length * multiplier): >> number_list[random.randint(0, length - 1)] += 1 >> minimum = mi

Re: Find in ipython3

2015-06-07 Thread Chris Angelico
On Sun, Jun 7, 2015 at 8:27 PM, Peter Otten <[email protected]> wrote: > Just wait for Python 3.5. The switch from os.listdir() to the (new) > os.scandir() in the implementation of os.walk() is likely to improve the > situation Why wait? I've been using 3.5 for ages (and actually, my /usr/local/bin

Re: Is it a newsgroup or a list?

2015-06-07 Thread Tim Golden
On 07/06/2015 12:20, [email protected] wrote: On Sun, Jun 7, 2015, at 05:06, Luca Menegotto wrote: Il 07/06/2015 10:22, Cecil Westerhof ha scritto: > That only times the function. I explicitly mentioned I want both the > needed time AND the output. > > Sadly the quality of the answer

Re: Is it a newsgroup or a list?

2015-06-07 Thread Luca Menegotto
Il 07/06/2015 13:45, Steven D'Aprano ha scritto: As far as I know, python-list a.k.a. comp.lang.python is the only one of the Python mailing lists with an official newsgroup mirror. OK. So let me rephrase: Thank God the list is mirrired to a newsgroup... -- Ciao! Luca -- https://mail.python

Detect if specific Python.app instance is already running

2015-06-07 Thread Andrei
Hello, I am experimenting with OS X apps written in Python and need to detect if there is already an instance of Python.app running with certain script. My script modifies CFBundleName on-the-fly from "Python" to "MyApp" to change the app title in the menubar. If I start another instance and ch

Re: Ah Python, you have spoiled me for all other languages

2015-06-07 Thread Chris Angelico
On Sun, Jun 7, 2015 at 11:24 PM, Steven D'Aprano wrote: >> (Unless you want to say that all strings are guaranteed to >> be NFC/NFD normalized, such that s1 and s2 would actually be >> identical, which I suppose is plausible. I'm not sure what the >> advantage would be, though. And certainly you w

Re: Ah Python, you have spoiled me for all other languages

2015-06-07 Thread random832
On Sun, Jun 7, 2015, at 07:42, Steven D'Aprano wrote: > The question of graphemes (what "ordinary people" consider letters and > characters, e.g. "ch" is two letters to an English speaker but one letter > to a Czech speaker) should be left to libraries. Do Czech speakers expect to be able to selec

Re: Ah Python, you have spoiled me for all other languages

2015-06-07 Thread Chris Angelico
On Mon, Jun 8, 2015 at 12:58 AM, wrote: > On Sun, Jun 7, 2015, at 07:42, Steven D'Aprano wrote: >> The question of graphemes (what "ordinary people" consider letters and >> characters, e.g. "ch" is two letters to an English speaker but one letter >> to a Czech speaker) should be left to libraries

Lawful != Mutable (was Can Python function return multiple data?)

2015-06-07 Thread Rustom Mody
On Saturday, June 6, 2015 at 11:13:52 AM UTC+5:30, Chris Angelico wrote: > On Sat, Jun 6, 2015 at 3:28 PM, Rustom Mody wrote: > > You just repeated what Chris said, replacing 'immutable' with 'same' > > There was a list: [1,2,3] > > At some point that list is found to be(come) [1,2,3,4] > > They d

Re: Is it a newsgroup or a list?

2015-06-07 Thread Gene Heskett
On Sunday 07 June 2015 09:57:55 Tim Golden wrote: > On 07/06/2015 12:20, [email protected] wrote: > > On Sun, Jun 7, 2015, at 05:06, Luca Menegotto wrote: > >> Il 07/06/2015 10:22, Cecil Westerhof ha scritto: > >> > That only times the function. I explicitly mentioned I want > >> > both t

Re: Testing random

2015-06-07 Thread Thomas 'PointedEars' Lahn
Chris Angelico wrote: > On Sun, Jun 7, 2015 at 8:40 PM, Thomas 'PointedEars' Lahn > wrote: >> Cecil Westerhof wrote: >>> I wrote a very simple function to test random: >>> def test_random(length, multiplier = 1): >>> number_list = length * [0] >>> for i in range(length * m

Re: Is it a newsgroup or a list?

2015-06-07 Thread Larry Martell
On Sun, Jun 7, 2015 at 11:49 AM, Gene Heskett wrote: > You mentioned GoogleGroups, now go warsh yur mouth out with some of > Grandma's Lye soap. This list is 500% easier to read when they are > filtered out. I still see the responses but they are at least formatted > for readability. Gene is ver

Re: Lawful != Mutable (was Can Python function return multiple data?)

2015-06-07 Thread Chris Angelico
On Mon, Jun 8, 2015 at 1:49 AM, Rustom Mody wrote: > On Saturday, June 6, 2015 at 11:13:52 AM UTC+5:30, Chris Angelico wrote: >> On Sat, Jun 6, 2015 at 3:28 PM, Rustom Mody wrote: >> > You just repeated what Chris said, replacing 'immutable' with 'same' >> > There was a list: [1,2,3] >> > At some

Re: Lawful != Mutable (was Can Python function return multiple data?)

2015-06-07 Thread Rustom Mody
On Saturday, June 6, 2015 at 10:20:49 AM UTC+5:30, Steven D'Aprano wrote: > On Sat, 6 Jun 2015 01:20 pm, Rustom Mody wrote: > > > On Saturday, June 6, 2015 at 3:30:23 AM UTC+5:30, Chris Angelico wrote: > > >> Congrats! You just proved that an object can itself be immutable, but > >> can contain r

Re: Testing random

2015-06-07 Thread Chris Angelico
On Mon, Jun 8, 2015 at 1:51 AM, Thomas 'PointedEars' Lahn wrote: > Chris Angelico wrote: > >> On Sun, Jun 7, 2015 at 8:40 PM, Thomas 'PointedEars' Lahn >> wrote: >>> Cecil Westerhof wrote: I wrote a very simple function to test random: def test_random(length, multiplier = 1): >>

Re: Ah Python, you have spoiled me for all other languages

2015-06-07 Thread Steven D'Aprano
On Mon, 8 Jun 2015 12:58 am, [email protected] wrote: > On Sun, Jun 7, 2015, at 07:42, Steven D'Aprano wrote: >> The question of graphemes (what "ordinary people" consider letters and >> characters, e.g. "ch" is two letters to an English speaker but one letter >> to a Czech speaker) should be

Re: Lawful != Mutable (was Can Python function return multiple data?)

2015-06-07 Thread Chris Angelico
On Mon, Jun 8, 2015 at 2:20 AM, Rustom Mody wrote: > Ok now rewrite that para above with > s/tuple/numbers like 3 or 666/ > So I put '3' on the ram and grind it to finest powder. > Have all trinities (of religious or secular variety) disappeared? > 666 gone has the devil been banished from God's (

Re: Testing random

2015-06-07 Thread Thomas 'PointedEars' Lahn
Peter Otten wrote: > Steven D'Aprano wrote: >>> I wrote a very simple function to test random: >>> def test_random(length, multiplier = 1): >>> number_list = length * [0] >>> for i in range(length * multiplier): >>> number_list[random.randint(0, length - 1)] +=

Re: Testing random

2015-06-07 Thread Thomas 'PointedEars' Lahn
Chris Angelico wrote: > On Mon, Jun 8, 2015 at 1:51 AM, Thomas 'PointedEars' Lahn > wrote: >> Chris Angelico wrote: >> >>> On Sun, Jun 7, 2015 at 8:40 PM, Thomas 'PointedEars' Lahn >>> wrote: Cecil Westerhof wrote: > I wrote a very simple function to test random: > def test_rand

Re: Testing random

2015-06-07 Thread Chris Angelico
On Mon, Jun 8, 2015 at 2:36 AM, Thomas 'PointedEars' Lahn wrote: >> The greater the multiplier, the lower the chance that any element will >> have no hits. > > Wrong. > >> [ex falso quodlibet] Huh. Do you want to explain how, mathematically, I am wrong, or do you want to join the RUE in my ignore

Re: Testing random

2015-06-07 Thread Peter Otten
Thomas 'PointedEars' Lahn wrote: > Peter Otten wrote: > >> Steven D'Aprano wrote: I wrote a very simple function to test random: def test_random(length, multiplier = 1): number_list = length * [0] for i in range(length * multiplier): nu

Re: Testing random

2015-06-07 Thread Ian Kelly
On Sun, Jun 7, 2015 at 10:44 AM, Chris Angelico wrote: > On Mon, Jun 8, 2015 at 2:36 AM, Thomas 'PointedEars' Lahn > wrote: >>> The greater the multiplier, the lower the chance that any element will >>> have no hits. >> >> Wrong. >> >>> [ex falso quodlibet] > > Huh. Do you want to explain how, ma

Python Random vs. Cython C Rand for Dice Rolls

2015-06-07 Thread C.D. Reimer
Greetings, I've revisited my misbegotten childhood by translating the programs from "BASIC Computer Games" by David H. Ahl into Python. This is mostly an exercise in unraveling spaghetti code with all those GOTO statements going all over the place. The dice program caught my attention in part

Re: Testing random

2015-06-07 Thread Chris Angelico
On Mon, Jun 8, 2015 at 3:07 AM, Ian Kelly wrote: > On Sun, Jun 7, 2015 at 10:44 AM, Chris Angelico wrote: >> On Mon, Jun 8, 2015 at 2:36 AM, Thomas 'PointedEars' Lahn >> wrote: The greater the multiplier, the lower the chance that any element will have no hits. >>> >>> Wrong. >>>

Re: Python Random vs. Cython C Rand for Dice Rolls

2015-06-07 Thread Chris Angelico
On Mon, Jun 8, 2015 at 3:17 AM, C.D. Reimer wrote: > This is the Python script that takes ~197 seconds to complete. > > import random, time > > startTime = time.time() > > f = [0] * 12 > > for i in range(5000): > > a = random.randint(1,6) > > b = random.randint(1,6) > > f[(a + b) -

Re: Python Random vs. Cython C Rand for Dice Rolls

2015-06-07 Thread Chris Angelico
On Mon, Jun 8, 2015 at 3:17 AM, C.D. Reimer wrote: > The Python random shows a uniform bell curve with low numbers at the ends > and the peak in the middle, which is similar to the text in the book for the > BASIC program. The Cython C rand is over all the place (especially with a > negative numbe

Re: Testing random

2015-06-07 Thread C.D. Reimer
On 6/7/2015 10:20 AM, Chris Angelico wrote: A fourth possibility is that mathematics works differently for him and for us, which I suppose is possible; when I visited sci.math a while ago, I found some people for whom everything I'd learned in grade school was clearly wrong, and they were doing t

Re: Python Random vs. Cython C Rand for Dice Rolls

2015-06-07 Thread C.D. Reimer
On 6/7/2015 10:23 AM, Chris Angelico wrote: Before you go any further, can you just try this script, please, and see how long it takes to run? import random, time startTime = time.time() for i in range(5000): pass print '\n', time.time() - startTime I know, seems a stupid thing to try,

Re: Python Random vs. Cython C Rand for Dice Rolls

2015-06-07 Thread Chris Angelico
On Mon, Jun 8, 2015 at 3:59 AM, C.D. Reimer wrote: > On 6/7/2015 10:23 AM, Chris Angelico wrote: >> >> Before you go any further, can you just try this script, please, and >> see how long it takes to run? >> >> import random, time >> startTime = time.time() >> for i in range(5000): >> pas

Re: Testing random

2015-06-07 Thread Steven D'Aprano
On Mon, 8 Jun 2015 01:51 am, Thomas 'PointedEars' Lahn wrote: > Chris Angelico wrote: > >> On Sun, Jun 7, 2015 at 8:40 PM, Thomas 'PointedEars' Lahn >> wrote: >>> Cecil Westerhof wrote: I wrote a very simple function to test random: def test_random(length, multiplier = 1):

Re: Testing random

2015-06-07 Thread Thomas 'PointedEars' Lahn
Chris Angelico wrote: > On Mon, Jun 8, 2015 at 2:36 AM, Thomas 'PointedEars' Lahn > wrote: >>> The greater the multiplier, the lower the chance that any element will >>> have no hits. >> Wrong. >> >>> [ex falso quodlibet] > > Huh. Do you want to explain how, mathematically, I am wrong, or do you

Re: Testing random

2015-06-07 Thread Steven D'Aprano
On Mon, 8 Jun 2015 02:36 am, Thomas 'PointedEars' Lahn wrote: > Chris Angelico wrote: >> The greater the multiplier, the lower the chance that any element will >> have no hits. > > Wrong. No, Chris is correct. The "multiplier" increases the number of samples. The larger the number of samples, t

Re: Python Random vs. Cython C Rand for Dice Rolls

2015-06-07 Thread Steven D'Aprano
On Mon, 8 Jun 2015 03:17 am, C.D. Reimer wrote: > Greetings, > > I've revisited my misbegotten childhood by translating the programs from > "BASIC Computer Games" by David H. Ahl into Python. This is mostly an > exercise in unraveling spaghetti code with all those GOTO statements > going all over

Re: Testing random

2015-06-07 Thread Chris Angelico
On Mon, Jun 8, 2015 at 4:28 AM, Steven D'Aprano wrote: > If my previous post didn't convince you, consider an even simpler random > distribution: tossing a fair coin. The probability of getting a head is > exactly 1/2 whether you toss the coin once or a thousand times. But if you > toss the coin o

Re: Python Random vs. Cython C Rand for Dice Rolls

2015-06-07 Thread C.D. Reimer
On 6/7/2015 10:33 AM, Chris Angelico wrote: The negative result is a strong indicator that you're not seeing the results of rand() here. While there is a potential for bias (check out RAND_MAX, and consider that there may be some small bias there; although on most modern systems, RAND_MAX is goin

Re: Testing random

2015-06-07 Thread Chris Angelico
On Mon, Jun 8, 2015 at 4:23 AM, Thomas 'PointedEars' Lahn wrote: > If the set to choose from is integer numbers from 1 to 9, then *each* of > those sequences has *the same* probability (1∕9)¹¹ ≈ 3.1866355 × 10⁻¹¹. > > AISB, those are *independent* events; the number of occurrences of an > outcome

Re: Python Random vs. Cython C Rand for Dice Rolls

2015-06-07 Thread Chris Angelico
On Mon, Jun 8, 2015 at 4:40 AM, C.D. Reimer wrote: > PS Z:\projects\programming\python\basic_games\fastdice> python > test_fastdice.py > > TOTAL SPOTS NUMBER OF TIMES > > 21389911 > > 3222 > > 44168248 > > 55553632 > > 6

Re: Python Random vs. Cython C Rand for Dice Rolls

2015-06-07 Thread C.D. Reimer
On 6/7/2015 11:33 AM, Steven D'Aprano wrote: C rand is not even close to random. The technical term for it is "shite". Looking through the BASIC book, I remembered all the tricks needed to get a half-way decent number generator on a 1MHz processor back in the day. Either the numbers start rep

Re: Function to show time to execute another function

2015-06-07 Thread Johannes Bauer
On 07.06.2015 10:22, Cecil Westerhof wrote: > That only times the function. I explicitly mentioned I want both the > needed time AND the output. And you also posted your solution. I fail to find any question in your original posting at all. > Sadly the quality of the answers on this list is goin

Re: Testing random

2015-06-07 Thread Jussi Piitulainen
Thomas 'PointedEars' Lahn writes: > Chris Angelico wrote: > >> Huh. Do you want to explain how, mathematically, I am wrong, or do >> you want to join the RUE in my ignore list? > > I already did; you have overlooked it. In a nutshell, the probability > of > > 1 1 1 1 1 1 1 1 1 1 1 There is one

Built-in Python3 web server functionality - wsgiref & http.server

2015-06-07 Thread Eric
I am trying to better understand the built-in python3 web server functionality and have just started reading the documentation. There seem to be two options provided by Python 3. 1. wsgiref https://docs.python.org/3/library/wsgiref.html 2. http.server https://docs.python.org/3/library/http.ser

Re: Testing random

2015-06-07 Thread Thomas 'PointedEars' Lahn
Jussi Piitulainen wrote: > Thomas 'PointedEars' Lahn writes: >> 8 3 6 3 1 2 6 8 2 1 6. > > There are more than four hundred thousand ways to get those numbers in > some order. > > (11! / 2! / 2! / 2! / 3! / 2! = 415800) Fallacy. Order is irrelevant here. -- PointedEars Twitter: @PointedEa

Re: Testing random

2015-06-07 Thread random832
On Sun, Jun 7, 2015, at 15:29, Thomas 'PointedEars' Lahn wrote: > Jussi Piitulainen wrote: > > > Thomas 'PointedEars' Lahn writes: > >> 8 3 6 3 1 2 6 8 2 1 6. > > > > There are more than four hundred thousand ways to get those numbers in > > some order. > > > > (11! / 2! / 2! / 2! / 3! / 2! =

Re: Testing random

2015-06-07 Thread Thomas 'PointedEars' Lahn
Chris Angelico wrote: > On Mon, Jun 8, 2015 at 4:23 AM, Thomas 'PointedEars' Lahn > wrote: >> If the set to choose from is integer numbers from 1 to 9, then *each* of >> those sequences has *the same* probability (1∕9)¹¹ ≈ 3.1866355 × 10⁻¹¹. >> >> AISB, those are *independent* events; the number

Re: Detect if specific Python.app instance is already running

2015-06-07 Thread Andrei
Alright, I have had some development in http://stackoverflow.com/questions/30694560/detect-if-specific-python-app-instance-is-already-running and can prevent running multiple instances of the same app/script (by lockf), but I still need to identify which Python.app instance is running certain s

Re: Python Random vs. Cython C Rand for Dice Rolls

2015-06-07 Thread Cecil Westerhof
On Sunday 7 Jun 2015 19:23 CEST, Chris Angelico wrote: > On Mon, Jun 8, 2015 at 3:17 AM, C.D. Reimer wrote: >> This is the Python script that takes ~197 seconds to complete. >> >> import random, time >> >> startTime = time.time() >> >> f = [0] * 12 >> >> for i in range(5000): >> >> a = rando

Re: Testing random

2015-06-07 Thread Thomas 'PointedEars' Lahn
[email protected] wrote: > On Sun, Jun 7, 2015, at 15:29, Thomas 'PointedEars' Lahn wrote: >> Jussi Piitulainen wrote: >> > Thomas 'PointedEars' Lahn writes: >> >> 8 3 6 3 1 2 6 8 2 1 6. >> > >> > There are more than four hundred thousand ways to get those numbers in >> > some order. >> >

Re: Testing random

2015-06-07 Thread Thomas 'PointedEars' Lahn
Peter Otten wrote: > Thomas 'PointedEars' Lahn wrote: >> Peter Otten wrote: >>> Steven D'Aprano wrote: > I wrote a very simple function to test random: > def test_random(length, multiplier = 1): > number_list = length * [0] > for i in range(length * multipl

Re: Embedded Python and C Callback functions

2015-06-07 Thread Stefan Behnel
[email protected] schrieb am 07.06.2015 um 10:56: > And I can't use Cython, because I have C++ module, and I have to use it. That's not a valid reason. Cython supports C++ code just fine. http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html Stefan -- https://mail.python.org/mailma

Re: Testing random

2015-06-07 Thread random832
On Sun, Jun 7, 2015, at 16:09, Thomas 'PointedEars' Lahn wrote: > No. AISB, those sequences all have the same probability: Yes and the probability of getting _any_ of the sequences, is the sum of the probabilities for each one of the sequences individually. -- https://mail.python.org/mailman/l

Re: Testing random

2015-06-07 Thread Thomas 'PointedEars' Lahn
[email protected] wrote: > On Sun, Jun 7, 2015, at 16:09, Thomas 'PointedEars' Lahn wrote: >> No. AISB, those sequences all have the same probability: > > Yes and the probability of getting _any_ of the sequences, is the sum of > the probabilities for each one of the sequences individually.

Re: Function to show time to execute another function

2015-06-07 Thread Cecil Westerhof
On Sunday 7 Jun 2015 20:51 CEST, Johannes Bauer wrote: > On 07.06.2015 10:22, Cecil Westerhof wrote: > >> That only times the function. I explicitly mentioned I want both >> the needed time AND the output. > > And you also posted your solution. I fail to find any question in > your original posti

Re: Testing random

2015-06-07 Thread Thomas 'PointedEars' Lahn
[email protected] wrote: > On Sun, Jun 7, 2015, at 16:09, Thomas 'PointedEars' Lahn wrote: >> No. AISB, those sequences all have the same probability: > > Yes and the probability of getting _any_ of the sequences, is the sum of > the probabilities for each one of the sequences individually.

Re: How to inverse a particle emitter

2015-06-07 Thread Denis McMahon
On Thu, 04 Jun 2015 16:15:20 -0700, stephenppraneel7 wrote: > hey, i really need help, im a straight up beginner in scripting and i > need to figure out how to make an inverted particle emitter using python > in maya An emitter of inverted particles? Or an inverted emitter? Or an absorber / acce

Re: Testing random

2015-06-07 Thread Ned Batchelder
On Sunday, June 7, 2015 at 2:26:02 PM UTC-4, Thomas 'PointedEars' Lahn wrote: > Chris Angelico wrote: > > > On Mon, Jun 8, 2015 at 2:36 AM, Thomas 'PointedEars' Lahn > > wrote: > >>> The greater the multiplier, the lower the chance that any element will > >>> have no hits. > >> Wrong. > >> > >>>

Is there a mail list like python-list in c?

2015-06-07 Thread Jimages
Hi! i know that the question may not be suitable. But i am learning python as well as c. And i find the list valuable. After google mail list about c. i don't find even one mail list t about programming in C. So could you recommend a mail list about programming in c? BTW excuse my bad English.

Query regarding sys.stdout.write

2015-06-07 Thread Sreenath Nair
Hi, I have a general query about the following snippet: import os Import sys for each_dir in os.listdir("/home/tmpuser"): full_path = os.path.join("/home/tmpuser", each_dir) sys.stdout.write("\r%s" % full_path) sys.stdout.flush() The snippet is a simplified example of me trying to pr

  1   2   >