[RELEASE] Python 3.6.0b4 is now available

2016-11-21 Thread Ned Deily
On behalf of the Python development community and the Python 3.6 release team, I'm pleased to announce the availability of Python 3.6.0b4. 3.6.0b4 is the last planned beta release of Python 3.6, the next major release of Python. Among the new major new features in Python 3.6 are: * PEP 468 - Pres

Re: Numpy slow at vector cross product?

2016-11-21 Thread Paul Rubin
Steven D'Aprano writes: > if we knew we should be doing it, and if we could be bothered to run > multiple trials and gather statistics and keep a close eye on the > deviation between measurements. But who wants to do that by hand? You might like this, for Haskell: http://www.serpentine.com/cr

Re: Can somebody tell me what's wrong wrong with my code? I don't understand

2016-11-21 Thread Steven D'Aprano
On Tuesday 22 November 2016 14:10, rmjbr...@gmail.com wrote: > Hi! This is my first post! I'm having trouble understanding my code. I get > "SyntaxError:invalid syntax" on line 49. Sometimes a syntax error can only be reported on the line *following* the line with the actual error. So you may ha

Re: Numpy slow at vector cross product?

2016-11-21 Thread Steven D'Aprano
On Tuesday 22 November 2016 14:00, Steve D'Aprano wrote: > Running a whole lot of loops can, sometimes, mitigate some of that > variation, but not always. Even when running in a loop, you can easily get > variation of 10% or more just at random. I think that needs to be emphasised: there's a lot

Re: Can somebody tell me what's wrong wrong with my code? I don't understand

2016-11-21 Thread Chris Angelico
On Tue, Nov 22, 2016 at 2:10 PM, wrote: > Hi! This is my first post! I'm having trouble understanding my code. I get > "SyntaxError:invalid syntax" on line 49. I'm trying to code a simple > text-based rpg on repl.it. Thank you for reading. > > > elif raceNum==3: > print("Nice fur. I don't see

Re: Can somebody tell me what's wrong wrong with my code? I don't understand

2016-11-21 Thread Larry Martell
On Mon, Nov 21, 2016 at 10:10 PM, wrote: > Hi! This is my first post! I'm having trouble understanding my code. I get > "SyntaxError:invalid syntax" on line 49. I'm trying to code a simple > text-based rpg on repl.it. Thank you for reading. > > > > print("Welcome to Gladiator Game! Choose your

Can somebody tell me what's wrong wrong with my code? I don't understand

2016-11-21 Thread rmjbros3
Hi! This is my first post! I'm having trouble understanding my code. I get "SyntaxError:invalid syntax" on line 49. I'm trying to code a simple text-based rpg on repl.it. Thank you for reading. print("Welcome to Gladiator Game! Choose your character race, class, and starting equipment!") pri

Re: Numpy slow at vector cross product?

2016-11-21 Thread Steve D'Aprano
On Tue, 22 Nov 2016 12:45 pm, BartC wrote: > On 21/11/2016 14:50, Steve D'Aprano wrote: >> On Mon, 21 Nov 2016 11:09 pm, BartC wrote: > >> Modern machines run multi-tasking operating systems, where there can be >> other processes running. Depending on what you use as your timer, you may >> be mea

Re: Numpy slow at vector cross product?

2016-11-21 Thread Steve D'Aprano
On Tue, 22 Nov 2016 05:43 am, BartC wrote: > The fastest I can get compiled, native code to do this is at 250 million > cross-products per second. Yes, yes, you're awfully clever, and your secret private language is so much more efficient than even C that the entire IT industry ought to hang the

Re: Numpy slow at vector cross product?

2016-11-21 Thread BartC
On 21/11/2016 14:50, Steve D'Aprano wrote: On Mon, 21 Nov 2016 11:09 pm, BartC wrote: Modern machines run multi-tasking operating systems, where there can be other processes running. Depending on what you use as your timer, you may be measuring the time that those other processes run. The OS c

Re: MemoryError and Pickle

2016-11-21 Thread Steve D'Aprano
On Tue, 22 Nov 2016 10:27 am, Fillmore wrote: > > Hi there, Python newbie here. > > I am working with large files. For this reason I figured that I would > capture the large input into a list and serialize it with pickle for > later (faster) usage. > Everything has worked beautifully until today

Re: Enigma 1140 - link problem

2016-11-21 Thread Terry Reedy
On 11/21/2016 5:45 PM, BlindAnagram wrote: Hi Jim, ... thanks Brian 'Brian', you sent this to python-list instead of Jim. If this is not spam, try again with a different 'To:' -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list

Re: MemoryError and Pickle

2016-11-21 Thread Steve D'Aprano
On Tue, 22 Nov 2016 11:40 am, Peter Otten wrote: > Fillmore wrote: > >> Hi there, Python newbie here. >> >> I am working with large files. For this reason I figured that I would >> capture the large input into a list and serialize it with pickle for >> later (faster) usage. > > But is it really

Re: MemoryError and Pickle

2016-11-21 Thread Chris Kaynor
On Mon, Nov 21, 2016 at 3:43 PM, John Gordon wrote: > In Fillmore > writes: > > >> Question for experts: is there a way to refactor this so that data may >> be filled/written/released as the scripts go and avoid the problem? >> code below. > > That depends on how the data will be read. Here is

Re: MemoryError and Pickle

2016-11-21 Thread Peter Otten
Fillmore wrote: > Hi there, Python newbie here. > > I am working with large files. For this reason I figured that I would > capture the large input into a list and serialize it with pickle for > later (faster) usage. But is it really faster? If the pickle is, let's say, twice as large as the or

Re: MemoryError and Pickle

2016-11-21 Thread John Gordon
In Fillmore writes: > Question for experts: is there a way to refactor this so that data may > be filled/written/released as the scripts go and avoid the problem? > code below. That depends on how the data will be read. Here is one way to do it: fileObject = open(filename, "w") for

MemoryError and Pickle

2016-11-21 Thread Fillmore
Hi there, Python newbie here. I am working with large files. For this reason I figured that I would capture the large input into a list and serialize it with pickle for later (faster) usage. Everything has worked beautifully until today when the large data (1GB) file caused a MemoryError :(

Enigma 1140 - link problem

2016-11-21 Thread BlindAnagram
Hi Jim, In my comment/solution for this Enigma I tried to post a link to my number theory library but my HTML got removed. Could you please replace the first sentence with: A solution using my http://173.254.28.24/~brgladma/number_theory.py";>number theory library: (without the line wrapping).

Re: Working around multiple files in a folder

2016-11-21 Thread Emile van Sebille
On 11/21/2016 11:27 AM, subhabangal...@gmail.com wrote: I have a python script where I am trying to read from a list of files in a folder and trying to process something. As I try to take out the output I am presently appending to a list. But I am trying to write the result of individual files

Working around multiple files in a folder

2016-11-21 Thread subhabangalore
I have a python script where I am trying to read from a list of files in a folder and trying to process something. As I try to take out the output I am presently appending to a list. But I am trying to write the result of individual files in individual list or files. The script is as follows:

Re: Which of two variants of code is better?

2016-11-21 Thread Victor Porton
Ned Batchelder wrote: > On Monday, November 21, 2016 at 12:48:25 PM UTC-5, Victor Porton wrote: >> Which of two variants of code to construct an "issue comment" object >> (about BitBucket issue comments) is better? >> >> 1. >> >> obj = IssueComment(Issue(IssueGroup(repository, 'issues'), id1), i

Re: Numpy slow at vector cross product?

2016-11-21 Thread BartC
On 21/11/2016 17:04, Nobody wrote: On Mon, 21 Nov 2016 14:53:35 +, BartC wrote: Also that the critical bits were not implemented in Python? That is correct. You'll notice that there aren't any loops in numpy.cross. It's just a wrapper around a bunch of vectorised operations (*, -, []). I

Re: Which of two variants of code is better?

2016-11-21 Thread Ned Batchelder
On Monday, November 21, 2016 at 12:48:25 PM UTC-5, Victor Porton wrote: > Which of two variants of code to construct an "issue comment" object (about > BitBucket issue comments) is better? > > 1. > > obj = IssueComment(Issue(IssueGroup(repository, 'issues'), id1), id2) > > or > > 2. > > list

Which of two variants of code is better?

2016-11-21 Thread Victor Porton
Which of two variants of code to construct an "issue comment" object (about BitBucket issue comments) is better? 1. obj = IssueComment(Issue(IssueGroup(repository, 'issues'), id1), id2) or 2. list = [('issues', IssueGroup), (id1, Issue), (id2, IssueComment)] obj = construct_subobject(reposito

Re: Numpy slow at vector cross product?

2016-11-21 Thread Nobody
On Mon, 21 Nov 2016 14:53:35 +, BartC wrote: > Also that the critical bits were not implemented in Python? That is correct. You'll notice that there aren't any loops in numpy.cross. It's just a wrapper around a bunch of vectorised operations (*, -, []). If you aren't taking advantage of vect

Re: Numpy slow at vector cross product?

2016-11-21 Thread Skip Montanaro
Perhaps your implementation isn't as general as numpy's? I pulled out the TestCross class from numpy.core.tests.test_numeric and replaced calls to np.cross with calls to your function. I got an error in test_broadcasting_shapes: ValueError: operands could not be broadcast together with shapes (1,2

Re: What is the difference between class Foo(): and class Date(object):

2016-11-21 Thread Veek M
Steve D'Aprano wrote: > On Mon, 21 Nov 2016 11:15 pm, Veek M wrote: > > class Foo(): >> ... pass >> ... > class Bar(Foo): >> ... pass >> ... > b = Bar() > type(b) >> > [...] > >> What is going on here? Shouldn't x = EuroDate(); type(x) give >> 'instance'?? Why is 'b' an 'inst

Re: Numpy slow at vector cross product?

2016-11-21 Thread BartC
On 21/11/2016 12:44, Peter Otten wrote: After a look into the source this is no longer a big surprise (numpy 1.8.2): if axis is not None: axisa, axisb, axisc=(axis,)*3 a = asarray(a).swapaxes(axisa, 0) b = asarray(b).swapaxes(axisb, 0) The situation may be different when

Re: Numpy slow at vector cross product?

2016-11-21 Thread Steve D'Aprano
On Mon, 21 Nov 2016 11:09 pm, BartC wrote: > On 21/11/2016 02:48, Steve D'Aprano wrote: [...] >> However, your code is not a great way of timing code. Timing code is >> *very* difficult, and can be effected by many things, such as external >> processes, CPU caches, even the function you use for ge

Re: What is the difference between class Foo(): and class Date(object):

2016-11-21 Thread Steve D'Aprano
On Mon, 21 Nov 2016 11:15 pm, Veek M wrote: class Foo(): > ... pass > ... class Bar(Foo): > ... pass > ... b = Bar() type(b) > [...] > What is going on here? Shouldn't x = EuroDate(); type(x) give > 'instance'?? Why is 'b' an 'instance' and 'x' EuroDate? > Why isn't 'b' B

Re: Numpy slow at vector cross product?

2016-11-21 Thread eryk sun
On Mon, Nov 21, 2016 at 1:38 AM, BartC wrote: > On 20/11/2016 20:46, DFS wrote: >> >> import sys, time, numpy as np >> loops=int(sys.argv[1]) >> >> x=np.array([1,2,3]) >> y=np.array([4,5,6]) >> start=time.clock() In Unix, time.clock doesn't measure wall-clock time, but rather an approximation to

ANN: eGenix PyRun - One file Python Runtime 2.2.3

2016-11-21 Thread eGenix Team: M.-A. Lemburg
ANNOUNCING eGenix PyRun - One file Python Runtime Version 2.2.3 An easy-to-use single file relocatable Python run-time - available for Linux, Mac OS X and Unix

Re: Generic dictionary

2016-11-21 Thread Peter Otten
Thorsten Kampe wrote: >> def GenericDict(dict_or_items): >> if isinstance(dict_or_items, dict): >> return dict(dict_or_items) >> else: >> return SimpleGenericDictWithOnlyTheFalseBranchesImplemented( >> dict_or_items >> ) > > That would be a kind of fact

Re: Setting the exit status from sys.excepthook

2016-11-21 Thread Peter Otten
Steven D'Aprano wrote: > I have script with an exception handler that takes care of writing the > traceback to syslog, and I set it as the global exceptionhook: > > sys.excepthook = my_error_handler > > > When my script raises, my_error_handler is called, as expected, and the > process exits wi

Re: Numpy slow at vector cross product?

2016-11-21 Thread Peter Otten
Steve D'Aprano wrote: > On Mon, 21 Nov 2016 07:46 am, DFS wrote: > >> import sys, time, numpy as np >> loops=int(sys.argv[1]) >> >> x=np.array([1,2,3]) >> y=np.array([4,5,6]) >> start=time.clock() >> for i in range(loops): >> np.cross(x,y) >> print "Numpy, %s loops: %.2g seconds" %(loops,ti

What is the difference between class Foo(): and class Date(object):

2016-11-21 Thread Veek M
>>> class Foo(): ... pass ... >>> class Bar(Foo): ... pass ... >>> b = Bar() >>> type(b) >>> class Date(object): ... pass ... >>> class EuroDate(Date): ... pass ... >>> x = EuroDate() >>> type(x) What is going on here? Shouldn't x = EuroDate(); type(x) give 'instance'?? Why is 'b' an

Re: Numpy slow at vector cross product?

2016-11-21 Thread BartC
On 21/11/2016 02:48, Steve D'Aprano wrote: On Mon, 21 Nov 2016 07:46 am, DFS wrote: start=time.clock() for i in range(loops): np.cross(x,y) print "Numpy, %s loops: %.2g seconds" %(loops,time.clock()-start) However, your code is not a great way of timing code. Timing code is *very* diff

Re: Clean way to return error codes

2016-11-21 Thread Peter Otten
Steven D'Aprano wrote: > I have a script that can be broken up into four subtasks. If any of those > subtasks fail, I wish to exit with a different exit code and error. > > Assume that the script is going to be run by system administrators who > know no Python and are terrified of tracebacks, and

Re: Guido? Where are you?

2016-11-21 Thread Ethan Furman
For those new to the list: Thomas 'PointedEars' Lahn has been banned from this mailing list for (at least) the rest of this year. Unfortunately, we do not have any control over the comp.lang.python newsgroup. If you access Python List from the newsgroup you may want to add him to your pers

Re: Guido? Where are you?

2016-11-21 Thread Bob Martin
in 767657 20161121 041134 Thomas 'PointedEars' Lahn wrote: >Tristan B. Kildaire wrote: > >> Is Guido active on this newsgroup. > >That is not even a question. > >> Sorry for the off-topic ness. > >There is no excuse for (such) stupidity. Stop postin

Re: Clean way to return error codes

2016-11-21 Thread Chris Angelico
On Mon, Nov 21, 2016 at 6:09 PM, Steven D'Aprano wrote: > try: > begin() > except BeginError: > print("error in begin") > sys.exit(3) Do you control the errors that are getting thrown? class BeginExit(SystemExit, BeginError): pass It'll behave like SystemExit, but still be catchable

Setting the exit status from sys.excepthook

2016-11-21 Thread Steven D'Aprano
I have script with an exception handler that takes care of writing the traceback to syslog, and I set it as the global exceptionhook: sys.excepthook = my_error_handler When my script raises, my_error_handler is called, as expected, and the process exits with status 1. How can I change the exi

Re: Clean way to return error codes

2016-11-21 Thread Steven D'Aprano
On Monday 21 November 2016 19:01, Ben Finney wrote: [...] > The next improvement I'd make is to use the “strategy” pattern, and come > up with some common key that determines what exit status you want. Maybe > the key is a tuple of (function, exception): > > exit_status_by_problem_key = { >

Re: Clean way to return error codes

2016-11-21 Thread Steven D'Aprano
On Monday 21 November 2016 18:39, Jussi Piitulainen wrote: > Steven D'Aprano writes: [...] >> It's not awful, but I don't really like the look of all those >> try...except blocks. Is there something cleaner I can do, or do I just >> have to suck it up? > > Have the exception objects carry the mes

Re: Clean way to return error codes

2016-11-21 Thread Ben Finney
Steven D'Aprano writes: > I have a script that can be broken up into four subtasks. If any of those > subtasks fail, I wish to exit with a different exit code and error. > > Assume that the script is going to be run by system administrators who > know no Python and are terrified of tracebacks, a