Re: How to make Python run as fast (or faster) than Julia

2018-02-27 Thread Christian Gollwitzer
Am 27.02.18 um 03:27 schrieb Chris Angelico: On Tue, Feb 27, 2018 at 12:57 PM, bartc wrote: Anyway, even this pure Python version can deliver pseudo random numbers at some 200,000 per second, while the built-in generator does 450,000 per second, so it's not bad going. The built-in generator

Re: Questions about `locals` builtin

2018-02-27 Thread Steven D'Aprano
On Mon, 26 Feb 2018 17:05:46 -0800, Dan Stromberg wrote: [...] > I don't have IronPython handy, but according my (quite possibly flawed) > test program, locals() is a copy on CPython 3, CPython 2, Pypy3, Pypy, > Jython and MicroPython. > > I didn't see any interpreters that returned the namespace

In Python2, does it need to wrap imp.find/load_module with imp_acquire/release_lock?

2018-02-27 Thread Xiang Zhang
Just like the title. It seems to me it is needed from the source code but codes in stdlib all doesn't do that. -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there are good DRY fix for this painful design pattern?

2018-02-27 Thread Wolfgang Maier
On 26.02.2018 15:41, Steven D'Aprano wrote: I have a class with a large number of parameters (about ten) assigned in `__init__`. The class then has a number of methods which accept *optional* arguments with the same names as the constructor/initialiser parameters. If those arguments are None, the

Re: Questions about `locals` builtin

2018-02-27 Thread Kirill Balunov
2018-02-27 2:57 GMT+03:00 Terry Reedy : > The point of point 3 is that terminology and details would likely be > different if Python were freshly designed more or less as it is today, and > some things only make more or less sense in historical context. Learn what > you need to know to write code

Re: How to make Python run as fast (or faster) than Julia

2018-02-27 Thread Ben Bacarisse
Christian Gollwitzer writes: > George Marsaglia is a researcher who invented a couple of PRNGs which > are both simple (one of the first was called KISS) yet surprisingly > good. s/is/was/ Sadly, he died a few years ago (2011). -- Ben. -- https://mail.python.org/mailman/listinfo/python-list

[newbie] how to remove empty lines from webpage/file

2018-02-27 Thread jenswaelkens
Dear all, I try to get the numerical data from the following webpage: http://www.astro.oma.be/GENERAL/INFO/nzon/zon_2018.html With the following code-fragment I was already able to get a partial result: #!/usr/bin/env python #memo: install bs4 as follows: sudo easy_install bs4 # -*- coding: utf-

Re: matrix multiplication

2018-02-27 Thread Peter Otten
Seb wrote: > On Tue, 27 Feb 2018 12:25:30 +1300, > Gregory Ewing wrote: > >> Seb wrote: >>> I was wondering is whether there's a faster way of multiplying each >>> row (1x3) of a matrix by another matrix (3x3), compared to looping >>> through the matrix row by row as shown in the code. > >> Jus

Re: How to make Python run as fast (or faster) than Julia

2018-02-27 Thread bartc
On 27/02/2018 02:27, Chris Angelico wrote: On Tue, Feb 27, 2018 at 12:57 PM, bartc wrote: On 27/02/2018 00:35, Chris Angelico wrote: Anyway, even this pure Python version can deliver pseudo random numbers at some 200,000 per second, while the built-in generator does 450,000 per second, so it

Re: Questions about `locals` builtin

2018-02-27 Thread Ned Batchelder
On 2/27/18 3:52 AM, Kirill Balunov wrote: a. Is this restriction for locals desirable in the implementation of CPython in Python 3? b. Or is it the result of temporary fixes for Python 2? My understanding is that the behavior of locals() is determined mostly by what is convenient for the imp

Re: How to make Python run as fast (or faster) than Julia

2018-02-27 Thread Steven D'Aprano
On Tue, 27 Feb 2018 11:27:21 +, bartc wrote: [...] >> The built-in generator is using a completely different algorithm >> though, so rate of generation isn't the entire story. How long is the >> period of the one you're using? (How long before it loops?) > > I believe it's 5*2**1320480*(2**64

Re: matrix multiplication

2018-02-27 Thread Ian Kelly
On Tue, Feb 27, 2018 at 4:08 AM, Peter Otten <__pete...@web.de> wrote: > Seb wrote: > >> On Tue, 27 Feb 2018 12:25:30 +1300, >> Gregory Ewing wrote: >> >>> Seb wrote: I was wondering is whether there's a faster way of multiplying each row (1x3) of a matrix by another matrix (3x3), compar

Re: Questions about `locals` builtin

2018-02-27 Thread Kirill Balunov
2018-02-27 14:59 GMT+03:00 Ned Batchelder : > On 2/27/18 3:52 AM, Kirill Balunov wrote: > >> a. Is this restriction for locals desirable in the implementation of >> CPython in Python 3? >> b. Or is it the result of temporary fixes for Python 2? >> > > My understanding is that the behavior of lo

Re: Is there are good DRY fix for this painful design pattern?

2018-02-27 Thread Kirill Balunov
This validation can be also done with the use of annotations, while I find it super awful, I put this for one more example: from functools import wraps def validate(func): @wraps(func) def _wrap(self, *args, **kwargs): variables = func.__annotations__.keys() kwargs.update(z

Re: [newbie] how to remove empty lines from webpage/file

2018-02-27 Thread Dan Stromberg
Perhaps replace: lines=soup.get_text() file.write(lines) ...with something like: text = soup.get_text() lines = text.split('\n') for line in lines: if line.strip(): file.write('%s\n' % (line, )) (untested) On Tue, Feb 27, 2018 at 2:50 AM, wrote: > Dear all, > I try to get the nume

Re: Is there are good DRY fix for this painful design pattern?

2018-02-27 Thread Kirill Balunov
Of course you can do the same without annotations, but with the introduction of private attribute while your API it is under active development: from functools import wraps def validate(func): @wraps(func) def _wrap(self, *args, **kwargs): variables = self._vars # Here kw

Re: matrix multiplication

2018-02-27 Thread Seb
On Tue, 27 Feb 2018 07:36:31 -0700, Ian Kelly wrote: > On Tue, Feb 27, 2018 at 4:08 AM, Peter Otten <__pete...@web.de> wrote: >> Seb wrote: >>> On Tue, 27 Feb 2018 12:25:30 +1300, >>> Gregory Ewing wrote: Seb wrote: > I was wondering is whether there's a faster way of multiplying

Re: help me ?

2018-02-27 Thread alister via Python-list
On Mon, 26 Feb 2018 01:40:16 -0800, sotaro237 wrote: > Define 2 lists. The first one must contain the integer values 1, 2 and 3 > and the second one the string values a, b and c. Iterate through both > lists to create another list that contains all the combinations of the A > and B elements. The f

Re: help me ?

2018-02-27 Thread Sir Real
On Mon, 26 Feb 2018 01:40:16 -0800 (PST), sotaro...@gmail.com wrote: >Define 2 lists. The first one must contain the integer values 1, 2 and 3 and >the second one the string values a, b and c. Iterate through both lists to >create another list that contains all the combinations of the A and B >

Re: help me ?

2018-02-27 Thread Igor Korot
Hi, On Tue, Feb 27, 2018 at 10:54 AM, Sir Real wrote: > On Mon, 26 Feb 2018 01:40:16 -0800 (PST), sotaro...@gmail.com wrote: > >>Define 2 lists. The first one must contain the integer values 1, 2 and 3 and >>the second one the string values a, b and c. Iterate through both lists to >>create ano

Re: matrix multiplication

2018-02-27 Thread Ian Kelly
On Tue, Feb 27, 2018 at 9:02 AM, Seb wrote: > That's right. I just tried this manipulation by replacing the last > block of code in my example, from the line above `for` loop with: > > ------ > # Alternative using `np.matmul` >

Re: help me ?

2018-02-27 Thread Ian Kelly
On Tue, Feb 27, 2018 at 10:16 AM, Igor Korot wrote: > Congratulations! > You have an "A" for solving the problem and "F" for helping the guy cheat. > You should be expelled from the course. In my experience, this is what happens pretty much every time. Somebody posts a homework question asking fo

Re: help me ?

2018-02-27 Thread Larry Martell
On Tue, Feb 27, 2018 at 12:56 PM, Ian Kelly wrote: > On Tue, Feb 27, 2018 at 10:16 AM, Igor Korot wrote: >> Congratulations! >> You have an "A" for solving the problem and "F" for helping the guy cheat. >> You should be expelled from the course. > > In my experience, this is what happens pretty m

Re: help me ?

2018-02-27 Thread Ziggy
On 2018-02-26, sotaro...@gmail.com wrote: > > Help me ! a=[1,2,3,] b=["a","b","c"] x=[] z=[] bonus=[] for digits in a: for letters in b: x.append(str(digits) + letters) bonus.append(letters + str(digits)) for letter in b: for number in a:

Re: help me ?

2018-02-27 Thread Grant Edwards
On 2018-02-27, Ian Kelly wrote: > On Tue, Feb 27, 2018 at 10:16 AM, Igor Korot wrote: >> Congratulations! >> You have an "A" for solving the problem and "F" for helping the guy cheat. >> You should be expelled from the course. > > In my experience, this is what happens pretty much every time. > S

Re: Is there are good DRY fix for this painful design pattern?

2018-02-27 Thread Jugurtha Hadjar
On 02/26/2018 03:41 PM, Steven D'Aprano wrote: I have a class with a large number of parameters (about ten) assigned in `__init__`. The class then has a number of methods which accept *optional* arguments with the same names as the constructor/initialiser parameters. If those arguments are None,

Cheetah 3.0.1

2018-02-27 Thread Oleg Broytman
Hello! I'm pleased to announce version 3.0.1, the first bugfix release of branch 3.0 of CheetahTemplate3. What's new in CheetahTemplate3 == Bug fixes: - Fix a minor bug in Compiler. What is CheetahTemplate3 Cheetah3 is a free and open s

Re: help me ?

2018-02-27 Thread Andre Müller
Hello, it's a duplicate: https://python-forum.io/Thread-Working-with-lists-homework-2 I have seen this more than one time. We don't like it. You keep people busy with one question at different places. You need two lists and one empty list. One outer loop iterating over the first list and one inn

Re: help me ?

2018-02-27 Thread Ian Kelly
On Tue, Feb 27, 2018 at 2:50 PM, Andre Müller wrote: > Hello, > > it's a duplicate: > https://python-forum.io/Thread-Working-with-lists-homework-2 > > I have seen this more than one time. We don't like it. You keep people busy > with one question at different places. You assume that it was posted

Re: Is there are good DRY fix for this painful design pattern?

2018-02-27 Thread Tim Chase
Something like the following might do the trick. As an added benefit, it's easy to set all the defaults automatically in __init__ as well without hand-adding "self.dopey = dopey". On the down side, in the non-__init__ functions, you have to use kwargs["dopey"] and the like. It also involves tackin

Re: help me ?

2018-02-27 Thread Steven D'Aprano
On Tue, 27 Feb 2018 10:56:18 -0700, Ian Kelly wrote: > Cheaters are gonna cheat. In the unlikely event they don't get the > answer here, they'll probably just manage to convince somebody to do the > work for them somewhere else. Honestly, I don't know if it's even worth > the bother to engage. It

Re: help me ?

2018-02-27 Thread Michael F. Stemper
On 2018-02-26 07:17, Stefan Ram wrote: Percival John Hackworth quoted: Define 2 lists. The first one must contain the integer values 1, 2 and 3 a =[ 1, 2, 3 ] and the second one the string values a, b and c. b =[ 'a', 'b', 'c'] Iterate through both lists to create another list that cont

psutil

2018-02-27 Thread Larry Martell
Trying to install psutil (with pip install psutil) on Red Hat EL 7. It's failing with: Python.h: No such file or directory Typically that means the python devel libs are not installed, but they are: [root@liszt ~]# yum install python-devel Package python-devel-2.7.5-58.el7.x86_64 already install

Re: psutil

2018-02-27 Thread Chris Angelico
On Wed, Feb 28, 2018 at 11:29 AM, Larry Martell wrote: > Trying to install psutil (with pip install psutil) on Red Hat EL 7. > It's failing with: > > Python.h: No such file or directory > > Typically that means the python devel libs are not installed, but they are: > > [root@liszt ~]# yum install

Re: psutil

2018-02-27 Thread José María Mateos
On Tue, Feb 27, 2018 at 07:29:50PM -0500, Larry Martell wrote: > Trying to install psutil (with pip install psutil) on Red Hat EL 7. > It's failing with: > > Python.h: No such file or directory Two questions come to my mind: - Does it work if you try to install some other package? - Is `pip` by

Re: psutil

2018-02-27 Thread Larry Martell
On Tue, Feb 27, 2018 at 7:37 PM, Chris Angelico wrote: > On Wed, Feb 28, 2018 at 11:29 AM, Larry Martell > wrote: >> Trying to install psutil (with pip install psutil) on Red Hat EL 7. >> It's failing with: >> >> Python.h: No such file or directory >> >> Typically that means the python devel lib

Re: psutil

2018-02-27 Thread Larry Martell
On Tue, Feb 27, 2018 at 7:36 PM, José María Mateos wrote: > On Tue, Feb 27, 2018 at 07:29:50PM -0500, Larry Martell wrote: >> Trying to install psutil (with pip install psutil) on Red Hat EL 7. >> It's failing with: >> >> Python.h: No such file or directory > > Two questions come to my mind: > > -

Re: psutil

2018-02-27 Thread Matt Wheeler
On Wed, 28 Feb 2018, 00:49 Larry Martell, wrote: > On Tue, Feb 27, 2018 at 7:36 PM, José María Mateos > wrote: > > On Tue, Feb 27, 2018 at 07:29:50PM -0500, Larry Martell wrote: > >> Trying to install psutil (with pip install psutil) on Red Hat EL 7. > >> It's failing with: > >> > >> Python.h: N

Re: psutil

2018-02-27 Thread Wildman via Python-list
On Tue, 27 Feb 2018 19:29:50 -0500, Larry Martell wrote: > Trying to install psutil (with pip install psutil) on Red Hat EL 7. > It's failing with: > > Python.h: No such file or directory > > Typically that means the python devel libs are not installed, but they are: > > [root@liszt ~]# yum ins

Re: help me ?

2018-02-27 Thread jladasky
On Tuesday, February 27, 2018 at 10:56:52 AM UTC-8, Grant Edwards wrote: > If the student is actively trying to avoid learning something, there's > nothing you can do to help them. They're just wasting their own time > and money. This is part of the reason why interviews for software developer jo

Re: help me ?

2018-02-27 Thread amber
On 02/27/2018 06:54 PM, Grant Edwards wrote: > The fun part is giving them a solution that's so obscure and "clever" > that it technically meets the stated requirement but is so far from > what the instructor wanted that they don't get credit for it (and > there's no way the student will be able

Re: help me ?

2018-02-27 Thread Rick Johnson
On Tuesday, February 27, 2018 at 12:56:52 PM UTC-6, Grant Edwards wrote: [...] > The fun part is giving them a solution that's so obscure and "clever" > that it technically meets the stated requirement but is so far from > what the instructor wanted that they don't get credit for it (and > there's

[RELEASE] Python 3.7.0b2 is now available for testing

2018-02-27 Thread Ned Deily
On behalf of the Python development community and the Python 3.7 release team, I'm happy to announce the availability of Python 3.7.0b2. b2 is the second of four planned beta releases of Python 3.7, the next major release of Python, and marks the end of the feature development phase for 3.7. You

Re: Questions about `locals` builtin

2018-02-27 Thread dieter
Kirill Balunov writes: > 2018-02-27 2:57 GMT+03:00 Terry Reedy : > >> The point of point 3 is that terminology and details would likely be >> different if Python were freshly designed more or less as it is today, and >> some things only make more or less sense in historical context. Learn what >>

Re: Questions about `locals` builtin

2018-02-27 Thread dieter
Ned Batchelder writes: > On 2/27/18 3:52 AM, Kirill Balunov wrote: >> a. Is this restriction for locals desirable in the implementation of >> CPython in Python 3? >> b. Or is it the result of temporary fixes for Python 2? > > My understanding is that the behavior of locals() is determined mostly

Re: Questions about `locals` builtin

2018-02-27 Thread Chris Angelico
On Tue, Feb 27, 2018 at 5:55 AM, Kirill Balunov wrote: > 2. The documentation has a note that "The contents of this dictionary > should not be modified". Which implies that it is a read only mapping. So > the question why it is `dict` instead of `types.MappingProxyType`? A dict is smaller and fas

Re: In Python2, does it need to wrap imp.find/load_module with imp_acquire/release_lock?

2018-02-27 Thread dieter
Xiang Zhang writes: > Just like the title. It seems to me it is needed from the source code but > codes in stdlib all doesn't do that. The "import" machinery uses locks of its own (to protect "sys.modules"). I assume that "load_module" will use those locks internally. "find" might be considere

Re: Questions about `locals` builtin

2018-02-27 Thread Chris Angelico
On Wed, Feb 28, 2018 at 5:54 PM, dieter wrote: > Ned Batchelder writes: >> On 2/27/18 3:52 AM, Kirill Balunov wrote: >>> a. Is this restriction for locals desirable in the implementation of >>> CPython in Python 3? >>> b. Or is it the result of temporary fixes for Python 2? >> >> My understandi