Re: Distance between point and a line passing through other two points

2018-02-07 Thread Chris Angelico
On Wed, Feb 7, 2018 at 10:06 PM, Dhananjay wrote: > Hello all, > > I have 3 points with coordinates (x0,y0,z0), (x1,y1,z1) and (x2,y2,z2). > I also have a line joining points (x1,y1,z1) and (x2,y2,z2). > For example, > p0=[5.0, 5.0, 5.0] > p1=[3.0, 3.0, 3.0] > p2=[4.0, 4.0, 4.0] > > a = np.array(p

Re: Where is _sre.SRE_Match?

2018-02-07 Thread Chris Angelico
On Thu, Feb 8, 2018 at 4:15 AM, Peng Yu wrote: > Hi, > > I see _sre.SRE_Match is returned by re.match. But I don't find where > it is defined. Does anybody know how to get its help page within > python command line? Thanks. > import re m = re.match('a', 'abc') print type(m) >

Re: Where is _sre.SRE_Match?

2018-02-07 Thread Chris Angelico
On Thu, Feb 8, 2018 at 4:57 AM, wrote: > On Wednesday, February 7, 2018 at 5:20:42 PM UTC, Chris Angelico wrote: >> On Thu, Feb 8, 2018 at 4:15 AM, Peng Yu wrote: >> > Hi, >> > >> > I see _sre.SRE_Match is returned by re.match. But I don't find where >

Re: This newsgroup (comp.lang.python) may soon be blocked by Google Gro

2018-02-08 Thread Chris Angelico
On Fri, Feb 9, 2018 at 9:35 AM, wrote: > On Sunday, February 4, 2018 at 12:15:16 AM UTC, pyotr filipivich wrote: > >> Those of us who do not use google-groups may not notice the loss >> of the google groupies. >> -- >> pyotr filipivich >> Next month's Panel: Graft - Boon or blessing? > >

Re: This newsgroup (comp.lang.python) may soon be blocked by Google Gro

2018-02-09 Thread Chris Green
and you've Surely you mean NNTP/Usenet client. > access to hundreds of Python lists and thousands of other technical > lists. I find the search facilities perfectly adequate. > -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list

Re: This newsgroup (comp.lang.python) may soon be blocked by Google Gro

2018-02-09 Thread Chris Green
Steven D'Aprano wrote: > On Fri, 09 Feb 2018 12:45:29 +0000, Chris Green wrote: > > > Mark Lawrence wrote: > [...] > >> Please don't waste your time with the gmane website. Just point any > >> (semi-)decent mail client like Thunderbird at news.gmane.o

Re: This newsgroup (comp.lang.python) may soon be blocked by Google Gro

2018-02-09 Thread Chris Green
vironment. If you can't even ssh from work then you can always use an 'ssh from the web' app from your wenb browser. The newsreader I use is tin by the way. -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list

Re: This newsgroup (comp.lang.python) may soon be blocked by Google Gro

2018-02-09 Thread Chris Angelico
On Sat, Feb 10, 2018 at 8:05 AM, wrote: > On Friday, February 9, 2018 at 2:48:17 PM UTC-5, Chris Green wrote: >> [email protected] wrote: >> > On Saturday, February 3, 2018 at 7:15:16 PM UTC-5, pyotr filipivich wrote: >> > > [snip] >> > > Those

Re: This newsgroup (comp.lang.python) may soon be blocked by Google Gro

2018-02-10 Thread Chris Green
Michael F. Stemper wrote: > On 2018-02-09 13:37, Chris Green wrote: > > > Alternative approach, what I do:- > > > > Run a text mode (but very capable and mouse aware) newsreader on > > my home system, read news locally using that. > > > >

Re: This newsgroup (comp.lang.python) may soon be blocked by Google Gro

2018-02-11 Thread Chris Angelico
On Sun, Feb 11, 2018 at 8:52 AM, Chris Green wrote: > Michael F. Stemper wrote: >> On 2018-02-09 13:37, Chris Green wrote: >> >> > Alternative approach, what I do:- >> > >> > Run a text mode (but very capable and mouse aware) newsreader on >>

Re: Defer, ensure library is loaded

2018-02-13 Thread Chris Angelico
On Wed, Feb 14, 2018 at 3:02 AM, Jason wrote: > I have a variety of scripts that import some large libraries, and rather than > create a million little scripts with specific imports, I'd like to so > something like > > psycopg2 = ensure_imported (psycopg2) > > This way, regardless of invocation

Re: Suggestions on programming in Python an email simple client

2018-02-13 Thread Chris Angelico
On Wed, Feb 14, 2018 at 7:05 AM, Maroso Marco wrote: > Hi, > > what i'm trying to do is develop my own email client, but a simple one. > > I just want it to connect to a specific email account and read the subject > line of messages coming from a certain email address. > > I then want it to be ab

Re: Getting "ValueError: need more than 1 value to unpack" while trying to read a value from dictionary in python

2018-02-15 Thread Chris Warrick
, you need to split it into lines, first stripping whitespace (starts and ends with an empty line). s = s.strip().replace("=",":") print s d = {} for i in s.split('\n'): try: key, val = i.split(":") d[key.strip()] = val.strip() except ValueError: print "no key:value pair found in", i (PS. please switch to Python 3) -- Chris Warrick <https://chriswarrick.com/> PGP: 5EAAEA16 -- https://mail.python.org/mailman/listinfo/python-list

Re: Python GIL vs CAS

2018-02-15 Thread Chris Angelico
On Thu, Feb 15, 2018 at 2:40 PM, Oleg Korsak wrote: > Hi. While hearing about GIL every time... is there any real reason why CAS > doesn't help to solve this problem? > > https://en.wikipedia.org/wiki/Compare-and-swap Because the GIL is not a problem. It's a feature. Before you ask about solution

Re: Python GIL vs CAS

2018-02-15 Thread Chris Angelico
On Fri, Feb 16, 2018 at 3:27 AM, Ned Batchelder wrote: > On 2/15/18 9:35 AM, Chris Angelico wrote: >> >> On Thu, Feb 15, 2018 at 2:40 PM, Oleg Korsak >> wrote: >>> >>> Hi. While hearing about GIL every time... is there any real reason why >>

Re: How to run script from interpreter?

2018-02-16 Thread Chris Angelico
On Sat, Feb 17, 2018 at 9:18 AM, windhorn wrote: > Yes, it's been covered, but not quite to my satisfaction. > > Here's an example simple script: > > # Very simple script > bar = 123 > > I save this as "foo.py" somewhere Python can find it > import foo bar > Traceback (most recent call l

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-16 Thread Chris Angelico
On Sat, Feb 17, 2018 at 2:22 PM, boB Stepp wrote: > This article is written by Nathan Murthy, a staff software engineer at > Tesla. The article is found at: > https://medium.com/@natemurthy/all-the-things-i-hate-about-python-5c5ff5fda95e > > Apparently he chose his article title as "click bait".

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-16 Thread Chris Angelico
On Sat, Feb 17, 2018 at 2:50 PM, Bill wrote: > boB Stepp wrote: >> >> This article is written by Nathan Murthy, a staff software engineer at >> Tesla. The article is found at: >> >> https://medium.com/@natemurthy/all-the-things-i-hate-about-python-5c5ff5fda95e >> >> Apparently he chose his articl

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-16 Thread Chris Angelico
On Sat, Feb 17, 2018 at 3:36 PM, Steven D'Aprano wrote: > Python is really good for gluing together high-performance but user- and > programmer-hostile scientific libraries written in C and Fortran. You > wouldn't write a serious, industrial-strength neural network in pure > Python code and expect

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-16 Thread Chris Angelico
On Sat, Feb 17, 2018 at 3:54 PM, boB Stepp wrote: > On Fri, Feb 16, 2018 at 10:05 PM, Ben Finney > wrote: > >> He blithely conflates “weakly typed” (Python objects are not weakly, but >> very strongly typed) with “dynamically typed” (yes, Python's name >> binding is dynamically typed). Those are

Re: Python 2 to 3 Conversion

2018-02-16 Thread Chris Angelico
On Sat, Feb 17, 2018 at 4:15 PM, Wildman via Python-list wrote: > I have a bit of code I found on the web that will return > the ip address of the named network interface. The code > is for Python 2 and it runs fine. But, I want to use the > code with Python 3. Below is the code followed by the

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-16 Thread Chris Angelico
On Sat, Feb 17, 2018 at 4:11 PM, boB Stepp wrote: > On Fri, Feb 16, 2018 at 10:25 PM, Chris Angelico wrote: > >> >> 1) Type safety. >> >> This is often touted as a necessity for industrial-grade software. It >> isn't... > > Chris, would you mind

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-16 Thread Chris Angelico
On Sat, Feb 17, 2018 at 5:25 PM, boB Stepp wrote: > I've just reread everyone's replies and one point you mentioned about > the GIL caught my eye ... > > On Fri, Feb 16, 2018 at 11:16 PM, Chris Angelico wrote: > >> Asynchronicity and concurrency are hard. Gettin

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-17 Thread Chris Angelico
On Sat, Feb 17, 2018 at 10:28 PM, Ben Bacarisse wrote: > Marko Rauhamaa writes: > >> Many people think static typing is key to high quality. I tend to think >> the reverse is true: the boilerplate of static typing hampers >> expressivity so much that, on the net, quality suffers. > > I don't fin

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-17 Thread Chris Angelico
On Sun, Feb 18, 2018 at 1:47 AM, Ian Kelly wrote: > On Fri, Feb 16, 2018 at 9:32 PM, Chris Angelico wrote: >> You'd be surprised how rarely that kind of performance even matters. >> The author of that article cites C# as a superior language, but in the >> rewrite from

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-17 Thread Chris Angelico
On Sun, Feb 18, 2018 at 5:05 AM, Steven D'Aprano wrote: > On Sat, 17 Feb 2018 15:25:15 +1100, Chris Angelico wrote: > >> 1) Type safety. >> >> This is often touted as a necessity for industrial-grade software. It >> isn't. There are many things that a typ

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-17 Thread Chris Angelico
On Sun, Feb 18, 2018 at 8:50 AM, bartc wrote: > On 17/02/2018 20:11, Chris Angelico wrote: >> >> On Sun, Feb 18, 2018 at 1:47 AM, Ian Kelly wrote: > > >>> Okay, I'm curious. How did C# force you to make extra HTTP requests >>> that were no longer neces

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-17 Thread Chris Angelico
On Sun, Feb 18, 2018 at 11:13 AM, bartc wrote: > On 17/02/2018 22:09, Chris Angelico wrote: >> >> On Sun, Feb 18, 2018 at 8:50 AM, bartc wrote: > > >>> That's a very interesting observation. >>> >>> I've frequently made the complaint ab

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-17 Thread Chris Angelico
On Sun, Feb 18, 2018 at 12:31 PM, bartc wrote: > On 18/02/2018 00:45, Chris Angelico wrote: >> >> On Sun, Feb 18, 2018 at 11:13 AM, bartc wrote: > > >> It's text, but it is an intermediate or "object" file. It's not doing >> pointless stuf

Re: Gmane seems to be gone

2018-02-18 Thread Chris Green
TP<->mailing-list gateway > continue to work -- until tonight. Now the domain is gone. Perhaps > it's just an oversight, but I've got a bad feeling... > I think it was a short term hiccough, a posting of mine got bounced yesterday but subsequent ones worked OK. --

Re: Python 2 to 3 Conversion

2018-02-18 Thread Chris Angelico
On Sun, Feb 18, 2018 at 4:35 AM, Wildman via Python-list wrote: > Thanks to Chris and Ben. Your suggestions were slightly > different but both worked equally well, although I don't > understand how that can be so. > >> struct.pack('256s', ifname[:15].enco

Python on Android?

2018-02-18 Thread Chris Angelico
Does anyone have experience with running Python scripts on Android phones? I have a brother (honestly! I'm not actually using a phone myself!) who's trying to run one of my scripts in QPython, which claims to be version 3.2.2. I think that really truly is a Python 3.2 implementation - probing for n

Re: Gmane seems to be gone

2018-02-18 Thread Chris Green
ting a > server from scratch wouldn't be too bad, either. > > However, the simplest way forward might be to just take an off-the-shelf > NNTP server and write a IMAP/NNTP gateway bot that acts as a client > bothways. Then you can use Python's nntplib and imaplib. > L

Re: Gmane seems to be gone

2018-02-18 Thread Chris Green
Grant Edwards wrote: > On 2018-02-18, Chris Green wrote: > > Grant Edwards wrote: > >> I've been dreading this moment for a couple years: it looks like > >> gmane.org is gone. The original operator/maintainer gave up a couple > >> years ago and pulled

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-18 Thread Chris Angelico
On Mon, Feb 19, 2018 at 1:14 PM, bartc wrote: > On 19/02/2018 00:09, Steven D'Aprano wrote: > >> Sure, but only the most boring, uninteresting kinds of types can be so >> named. The point is that "sufficiently fine-grained types" can be >> arbitrarily complex. > > > I don't think so. > > If a hum

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-19 Thread Chris Angelico
On Mon, Feb 19, 2018 at 7:40 PM, Alain Ketterlin wrote: > Tim Delaney writes: >> C is statically and weakly typed. Variables know their types at compile >> time (static typing). It is a feature of the language that you can cast any >> pointer to any chunk of memory to be a pointer to any other ty

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-19 Thread Chris Angelico
On Mon, Feb 19, 2018 at 8:36 PM, Antoon Pardon wrote: > On 17-02-18 21:11, Chris Angelico wrote: >> On Sun, Feb 18, 2018 at 1:47 AM, Ian Kelly wrote: >>> On Fri, Feb 16, 2018 at 9:32 PM, Chris Angelico wrote: >>>> You'd be surprised how rarely that kind of

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-19 Thread Chris Angelico
On Mon, Feb 19, 2018 at 9:04 PM, Alain Ketterlin wrote: > Chris Angelico writes: > >> On Mon, Feb 19, 2018 at 7:40 PM, Alain Ketterlin >> wrote: > >>> No. C has much stronger rules, not on casting, but on accessing the >>> pointees, which basically in

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-19 Thread Chris Angelico
On Mon, Feb 19, 2018 at 9:24 PM, Steven D'Aprano wrote: > On Mon, 19 Feb 2018 09:40:09 +0100, Alain Ketterlin wrote: > >> Tim Delaney writes: >> >> [...] >>> As others have said, typing is about how the underlying memory is >>> treated. >> >> No. It is much more than that. Typing is about everyth

Re: [OT] multicore/cpu history Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-19 Thread Chris Angelico
On Mon, Feb 19, 2018 at 10:39 PM, Adriaan Renting wrote: > I remember running 2 Mendocino 300 MHz Celerons on a Pentium II Xeon > motherboard to get a > multi-cpu machine for running multiple virtual machines for testing > purposes around 1998. > This was not as Intel intended, but a quite cheap c

Re: Python 2 to 3 Conversion

2018-02-19 Thread Chris Angelico
On Mon, Feb 19, 2018 at 11:32 PM, Rhodri James wrote: > On 18/02/18 16:18, Wildman via Python-list wrote: >>> >>> But that's only going to show one (uplink) address. If I needed to get >>> ALL addresses for ALL network adapters, I'd either look for a library, >>> and if one wasn't easily found, I'

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-19 Thread Chris Angelico
On Tue, Feb 20, 2018 at 12:34 AM, Steven D'Aprano wrote: > On Mon, 19 Feb 2018 20:14:32 +1100, Chris Angelico wrote: > >> As an integer, 3.141590 is 107853 $ >> >> Looks to me like C is perfectly happy to interpret a float as an int. > > Yes, but that'

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-19 Thread Chris Angelico
On Mon, Feb 19, 2018 at 11:35 PM, bartc wrote: > Sometimes, the reason for creating a special numerical type is precisely so > you can't do arithmetic on them, if it's not meaningful for the type. > > So the special type of the values 65..90 might not allow the type be > multiplied or divided, or

Re: Python 2 to 3 Conversion

2018-02-19 Thread Chris Angelico
On Tue, Feb 20, 2018 at 3:49 AM, Wildman via Python-list wrote: > On Mon, 19 Feb 2018 12:32:49 +, Rhodri James wrote: > >> On 18/02/18 16:18, Wildman via Python-list wrote: But that's only going to show one (uplink) address. If I needed to get ALL addresses for ALL network adapters,

Re: Python 2 to 3 Conversion

2018-02-19 Thread Chris Angelico
On Tue, Feb 20, 2018 at 3:53 AM, Wildman via Python-list wrote: > On Tue, 20 Feb 2018 02:26:19 +1100, Chris Angelico wrote: > >> * Opaque IOCTLs > > Would you mind to elaborate a little about your > concerns? Look at your original code: it's impossible to figure out

Re: [ANN] Biovarase ver 2

2018-02-19 Thread Chris Angelico
On Tue, Feb 20, 2018 at 8:45 AM, Beppe wrote: > > Biovarase has been updated to version 2, > > The project has been migrated from python 2.7 to python 3.5 > > Biovarase is an application to manage clinical quality control data. > > The purpose of Quality Control Assurance in a clinical laboratory

Re: How to link to python 3.6.4 library on linux ?

2018-02-19 Thread Chris Angelico
On Tue, Feb 20, 2018 at 8:07 AM, Jason Qian via Python-list wrote: > Hi, > > I am calling python from a c application. > It compiles and works fine on the windows. How do I compile and link > it on the linux for Python 3.6.4 ? > > Under python dir, it only have a static librar

Re: Python 2 to 3 Conversion

2018-02-19 Thread Chris Angelico
On Tue, Feb 20, 2018 at 10:09 AM, Wildman via Python-list wrote: > Yes, you are correct. Third-party pip packages are always > a no-no. > > Speaking of which, there is a library called Netifaces that > will easily do exactly what I want with a few lines of code. > But, it is not to be found in an

Re: Python 2 to 3 Conversion

2018-02-19 Thread Chris Angelico
On Tue, Feb 20, 2018 at 12:05 PM, Wildman via Python-list wrote: > On Tue, 20 Feb 2018 10:55:28 +1100, Chris Angelico wrote: > >> The given homepage URL is >> http://alastairs-place.net/projects/netifaces/ - is that the right >> one? >> >> ChrisA > > Yes,

Re: Python on Android?

2018-02-20 Thread Chris Angelico
On Mon, Feb 19, 2018 at 3:57 AM, Johannes Findeisen wrote: > On Sun, 18 Feb 2018 20:57:02 +1100 > Chris Angelico wrote: > >> Does anyone have experience with running Python scripts on Android >> phones? I have a brother (honestly! I'm not actually using a phone >>

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-20 Thread Chris Angelico
On Wed, Feb 21, 2018 at 12:38 AM, Antoon Pardon wrote: > Why should this be done at compile time? I say a static language can do > the same as a dynamic language and your counter point is to ask for how > that static language can do something extra. > > The point I am making is that you claim dyna

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-20 Thread Chris Angelico
On Wed, Feb 21, 2018 at 12:53 AM, Antoon Pardon wrote: > In C++ I can do something like: > > SomeClass MyVar; > > And after that the kind of possible assignments to MyVar are constraint. It > makes the runtime throw an error when somewhere the program tries to assign > something to MyVar that is

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-20 Thread Chris Angelico
On Wed, Feb 21, 2018 at 7:42 AM, Rick Johnson wrote: > On Tuesday, February 20, 2018 at 2:18:31 PM UTC-6, MRAB wrote: > >> The point he was making is that if you store a person's age, you'd have >> to update it every year. It's far better to store the date of birth and >> calculate the age on dema

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-20 Thread Chris Angelico
On Wed, Feb 21, 2018 at 9:01 AM, Rick Johnson wrote: > On Tuesday, February 20, 2018 at 2:51:56 PM UTC-6, Chris Angelico wrote: > [...] >> Nope. Even if you need the age many times per second, it's still >> better to store the date of birth, because you eliminate bou

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-20 Thread Chris Angelico
On Wed, Feb 21, 2018 at 6:39 AM, Geldenhuys, J, Prof wrote: > I think your case illustrates the Python/Mathematica issue well: you found a > job for which Mathematica was not the perfect tool and you used Python. At > the end of the day, both M & P have their place. For example, we probably

Re: Python on Android?

2018-02-20 Thread Chris Angelico
On Wed, Feb 21, 2018 at 4:44 PM, Abdur-Rahmaan Janhangeer wrote: > here is a kivy launcher tutorial i once wrote : > https://wp.me/p7UB6x-kB > Thanks. I'm currently a dozen or so tabs deep into learning Kivy, and am just starting to get to looking into launchers. ChrisA -- https://mail.python.o

Re: Python to Julia code generator?

2018-02-21 Thread Chris Angelico
On Wed, Feb 21, 2018 at 9:04 PM, Steven D'Aprano wrote: > On Wed, 21 Feb 2018 04:13:56 -0500, Etienne Robillard wrote: > >> Hi, >> >> Would it be possible to build a Python to Julia code generator?? >> >> i'm interested to learn Julia and would love to have the capacity to >> embed or run native P

Re: Python on Android?

2018-02-21 Thread Chris Angelico
On Wed, Feb 21, 2018 at 10:11 AM, Johannes Findeisen wrote: > Don't know which Python version is included in Kivy Launcher and believe > it is 2.7. but it think Kivy will go over to Python 3.* in the near > future. > Well... after an insane number of attempts, most of which were at least partiall

Re: atws

2018-02-21 Thread Chris Angelico
On Thu, Feb 22, 2018 at 5:27 PM, Larry Martell wrote: > I want to use the atws package > (https://atws.readthedocs.io/readme.html). I am using python 2.7.6 on > ubuntu-trusty-64 3.13.0-87-generic. I get this error when importing > the package: > import atws > Traceback (most recent call last)

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

2018-02-22 Thread Chris Angelico
On Thu, Feb 22, 2018 at 11:03 PM, bartc wrote: > On 22/02/2018 10:59, Steven D'Aprano wrote: >> >> >> https://www.ibm.com/developerworks/community/blogs/jfp/entry/Python_Meets_Julia_Micro_Performance?lang=en > > > While an interesting article on speed-up techniques, that seems to miss the > point

Re: atws

2018-02-22 Thread Chris Angelico
On Fri, Feb 23, 2018 at 2:06 AM, Larry Martell wrote: > On Thu, Feb 22, 2018 at 2:00 AM, Chris Angelico wrote: >> For reference, here's the version of requests that I have (which does >> have that exception available): >> >>>>> import requests >>&g

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

2018-02-22 Thread Chris Angelico
On Fri, Feb 23, 2018 at 12:51 AM, Serhiy Storchaka wrote: > 22.02.18 14:29, Chris Angelico пише: >> >> Not overly misleading; the point of it is to show how trivially easy >> it is to memoize a function in Python. For a fair comparison, I'd like >> to see the equ

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

2018-02-22 Thread Chris Angelico
On Fri, Feb 23, 2018 at 2:15 AM, ast wrote: > Le 22/02/2018 à 13:03, bartc a écrit : >> >> On 22/02/2018 10:59, Steven D'Aprano wrote: >>> >>> >>> https://www.ibm.com/developerworks/community/blogs/jfp/entry/Python_Meets_Julia_Micro_Performance?lang=en >> >> >> While an interesting article on spee

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

2018-02-22 Thread Chris Angelico
On Fri, Feb 23, 2018 at 3:00 AM, Steven D'Aprano wrote: > On Thu, 22 Feb 2018 12:03:09 +, bartc wrote: >> Here's another speed-up I found myself, although it was only 50 times >> faster, not 17,000: just write the code in C, and call it via >> os.system("fib.exe"). > > Did you include the time

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

2018-02-22 Thread Chris Angelico
On Fri, Feb 23, 2018 at 11:31 AM, Steven D'Aprano wrote: > Big O analysis is never a substitute for actual timing measurements, and > the assumption behind Big O analysis, namely that only some operations > take time, and always constant time, is never correct. It is only an > approximation to the

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

2018-02-23 Thread Chris Angelico
On Fri, Feb 23, 2018 at 5:38 PM, Terry Reedy wrote: > As to the vague 'class of problems implemented in a similar manner': Any > function f of count N that depends of values of f for counts < N can be > memoized the same way in Python as fibonacci. Everything said about P vs J > for fib applies t

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

2018-02-23 Thread Chris Angelico
On Fri, Feb 23, 2018 at 11:17 PM, bartc wrote: >>> The fact is that the vast majority of integer calculations don't need to >>> use big integers (pretty much 100% of mine). Probably most don't even >>> need 64 bits, but 32 bits. >> >> >> And here we have the World According To Bart again: "since *

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

2018-02-23 Thread Chris Angelico
On Fri, Feb 23, 2018 at 11:57 PM, bartc wrote: > On 23/02/2018 08:11, Terry Reedy wrote: > >> * Python has an import statement. But 'comparisons' disallow 'import >> numpy', a quite legal Python statement, and similar others. > > > If I'm duplicating a benchmark [in another language] then the las

Re: atws

2018-02-23 Thread Chris Angelico
On Sat, Feb 24, 2018 at 12:08 AM, Larry Martell wrote: > On Fri, Feb 23, 2018 at 2:01 AM, dieter wrote: >> Larry Martell writes: >>> ... >>> I had 2.2.1. I updated requests to 2.18.4 and now when I import atws I get: >>> >>> No handlers could be found for logger "atws.connection" >> >> This is a

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

2018-02-23 Thread Chris Angelico
On Sat, Feb 24, 2018 at 3:32 AM, Python wrote: > On Fri, Feb 23, 2018 at 03:11:36AM -0500, Terry Reedy wrote: >> >>Why do you care about the 50 million calls? That's crazy -- the important >> >>thing is *calculating the Fibonacci numbers as efficiently as possible*. >> >> >If you are writing pract

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

2018-02-23 Thread Chris Angelico
On Sat, Feb 24, 2018 at 3:39 AM, Steven D'Aprano wrote: > On Fri, 23 Feb 2018 23:41:44 +1100, Chris Angelico wrote: > > [...] >>> Integer pixel values >> >> Maybe in 64 bits for the time being, but 32 certainly won't be enough. >> As soon as you d

Re: atws

2018-02-23 Thread Chris Angelico
On Sat, Feb 24, 2018 at 12:41 AM, Larry Martell wrote: > On Fri, Feb 23, 2018 at 8:34 AM, Chris Angelico wrote: >> On Sat, Feb 24, 2018 at 12:08 AM, Larry Martell >> wrote: >>> On Fri, Feb 23, 2018 at 2:01 AM, dieter wrote: >>>> Larry Martell writes: &g

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

2018-02-23 Thread Chris Angelico
On Sat, Feb 24, 2018 at 4:49 AM, Steven D'Aprano wrote: > On Sat, 24 Feb 2018 00:03:06 +1100, Chris Angelico wrote: > >>> Is numpy a general purpose C library that can also be called from any >>> language that can use a C API? Or is it specific to Python? >>

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

2018-02-23 Thread Chris Angelico
On Sat, Feb 24, 2018 at 5:05 AM, Steven D'Aprano wrote: > But guess what? The benchmarks are flawed. The performance of real-world > Julia code doesn't match the performance of the benchmarks. > > "What’s disappointing is the striking difference between > the claimed performance and the ob

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

2018-02-23 Thread Chris Angelico
On Sat, Feb 24, 2018 at 5:43 AM, Python wrote: > On Sat, Feb 24, 2018 at 03:42:43AM +1100, Chris Angelico wrote: >> >> If that were so, then the comparison should use the fastest *Python* >> >> implementation. >> > >> > Doing that would completely fail

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

2018-02-23 Thread Chris Angelico
On Sat, Feb 24, 2018 at 6:09 AM, Python wrote: > On Sat, Feb 24, 2018 at 05:56:25AM +1100, Chris Angelico wrote: >> No, not satisfied. Everything you've said would still be satisfied if >> all versions of the benchmark used the same non-recursive algorithm. >> There

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

2018-02-23 Thread Chris Angelico
On Sat, Feb 24, 2018 at 6:25 AM, bartc wrote: > On 23/02/2018 18:05, Steven D'Aprano wrote: >> >> On Fri, 23 Feb 2018 13:51:33 +, Ben Bacarisse wrote: > > >> Stop writing crap code and then complaining that the language is "too >> slow". Write better code, and then we'll take your complaints s

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

2018-02-23 Thread Chris Angelico
On Sat, Feb 24, 2018 at 7:02 AM, bartc wrote: > On 23/02/2018 19:47, Chris Angelico wrote: >> >> On Sat, Feb 24, 2018 at 6:25 AM, bartc wrote: > > >>> The difference between Python and another dynamic language might be a >>> magnitude, yet you say it doesn&

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

2018-02-23 Thread Chris Angelico
On Sat, Feb 24, 2018 at 8:32 AM, bartc wrote: > So I'll keep it generic. Let's say the Tiny C compiler is not taken > seriously because it might be a couple of times slower than gcc-O3, even > thought it's 1% of the size and compiles 1000% as fast. Except that nobody has said that. You're doing a

Re: read Unicode characters one by one in python2

2018-02-25 Thread Chris Warrick
ython No, it’s terrible. So is the Python 3 version. All you need for both Pythons is this: import io with io.open('input.txt', 'r', encoding='utf-8') as fh: for character in fh: print(character) (and please make sure you need to read character-

Re: read Unicode characters one by one in python2

2018-02-25 Thread Chris Angelico
On Mon, Feb 26, 2018 at 12:33 AM, Chris Warrick wrote: > On 24 February 2018 at 17:17, Peng Yu wrote: >> Here shows some code for reading Unicode characters one by one in >> python2. Is it the best code for reading Unicode characters one by one >> in python2? >> >

Re: read Unicode characters one by one in python2

2018-02-25 Thread Chris Angelico
On Mon, Feb 26, 2018 at 3:57 AM, Steven D'Aprano wrote: > On Mon, 26 Feb 2018 01:50:16 +1100, Chris Angelico wrote: > >> If you actually need character-by-character, you'd need "for character >> in fh.read()" rather than iterating over the file itself.

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

2018-02-25 Thread Chris Angelico
On Mon, Feb 26, 2018 at 1:33 PM, Rick Johnson wrote: > On Friday, February 23, 2018 at 10:41:45 AM UTC-6, Steven D'Aprano wrote: > [...] >> There are dozens of languages that have made the design >> choice to limit their default integers to 16- 32- or 64-bit >> fixed size, and let the user worry a

Re: For Loop Dilema [python-list]

2018-02-25 Thread Chris Angelico
On Mon, Feb 26, 2018 at 5:19 AM, wrote: > Why we don’t use: > > for _ in _ in _ > > Instead of > > for _ in _: > for _ in _: > > Ex: > > Names = ["Arya","Pupun"] > > for name in Names: >for c in name: >print(c) > > instead use: > > for c in name in Names: > print(c) B

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

2018-02-26 Thread Chris Angelico
On Mon, Feb 26, 2018 at 8:57 PM, Steven D'Aprano wrote: > On Sun, 25 Feb 2018 20:22:17 -0800, Rick Johnson wrote: > >> So of course, speed is not and should not be the >> primary concern, but to say that execution speed is of _no_ concern is >> quite absurd indeed. > > I'm pretty sure that nobody

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

2018-02-26 Thread Chris Angelico
On Mon, Feb 26, 2018 at 10:13 PM, bartc wrote: > Below is the first draft of a Python port of a program to do with random > numbers. (Ported from my language, which in turned ported it from a C > program by George Marsaglia, the random number guy.) > > However, running it quickly exhausts the memo

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

2018-02-26 Thread Chris Angelico
On Tue, Feb 27, 2018 at 12:03 AM, Steven D'Aprano wrote: > On Mon, 26 Feb 2018 22:34:00 +1100, Chris Angelico wrote: >> Removing the GIL from CPython is not about "speeding up" the language or >> the interpreter, but about improving parallelism. > > It is abou

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

2018-02-26 Thread Chris Angelico
On Tue, Feb 27, 2018 at 1:41 AM, 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 argu

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

2018-02-26 Thread Chris Angelico
On Tue, Feb 27, 2018 at 2:02 AM, bartc wrote: > On 26/02/2018 14:04, bartc wrote: >> >> On 26/02/2018 13:42, Ned Batchelder wrote: > > >> Well, once you notice that the >>> >>> Python code had N=1e5, and the C code had N=1e9 :) If you want to >>> experiment, with N=1e5, the final number should

Re: Implicit conversion to str in str.join method?

2018-02-26 Thread Chris Angelico
On Tue, Feb 27, 2018 at 6:38 AM, Kirill Balunov wrote: > Currently `str.join` raises `TypeError` if there are any non-string values > in iterable, including `bytes` objects. Is it an awful idea to implicitly > _cast_ elements in iterable to their `str` or `repr` representation? Was > this question

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

2018-02-26 Thread Chris Angelico
On Tue, Feb 27, 2018 at 6:37 AM, Rick Johnson wrote: > On Monday, February 26, 2018 at 4:39:22 AM UTC-6, Steven D'Aprano wrote: >> On Sun, 25 Feb 2018 19:26:12 -0800, Rick Johnson wrote: >> >> > On Friday, February 23, 2018 at 8:48:55 PM UTC-6, Steven D'Aprano wrote: >> > [...] >> > > Take the Fib

Re: Implicit conversion to str in str.join method?

2018-02-26 Thread Chris Angelico
On Tue, Feb 27, 2018 at 6:54 AM, Kirill Balunov wrote: >> print(*iterable, sep=", ") > > > Thanks, I apologize :-) and why I always manage to find complicated ways... Hey, that's why we have the list :) I call this a success. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

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

2018-02-26 Thread Chris Angelico
On Tue, Feb 27, 2018 at 11:17 AM, Steven D'Aprano wrote: > On Tue, 27 Feb 2018 02:09:53 +1100, Chris Angelico wrote: > >> You're still reimplementing the C code in Python, which is inefficient. >> Have you considered going back to the *actual algorithm* and >>

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

2018-02-26 Thread Chris Angelico
On Tue, Feb 27, 2018 at 12:57 PM, bartc wrote: > On 27/02/2018 00:35, Chris Angelico wrote: >> >> On Tue, Feb 27, 2018 at 11:17 AM, Steven D'Aprano >> wrote: >>> >>> On Tue, 27 Feb 2018 02:09:53 +1100, Chris Angelico wrote: >>> >>&g

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-26 Thread Chris Angelico
On Tue, Feb 27, 2018 at 12:18 PM, Rick Johnson wrote: > On Tuesday, February 20, 2018 at 5:45:36 PM UTC-6, Steven D'Aprano wrote: >> On Tue, 20 Feb 2018 12:42:23 -0800, Rick Johnson wrote: >> >> > For instance, if the age is queried many times a second, >> > it would be a much wiser design to set-

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-26 Thread Chris Angelico
On Tue, Feb 27, 2018 at 2:55 PM, Ian Kelly wrote: > On Mon, Feb 26, 2018 at 8:09 PM, Steven D'Aprano > wrote: >> Yes you did: "the last second of every year" is always 23:59:59 of 31st >> December, and it is always the same time and date "every year". > > Except when it's 23:59:60 or 23:59:61 (wh

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: 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: 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

Re: Questions about `locals` builtin

2018-02-28 Thread Chris Angelico
On Wed, Feb 28, 2018 at 10:58 PM, Steven D'Aprano wrote: > On Wed, 28 Feb 2018 18:04:11 +1100, Chris Angelico wrote: >> But if you know that >> there's only a handful of variables that you'd actually want to do that >> to, you can simply put those into an obj

<    40   41   42   43   44   45   46   47   48   49   >