Re: Why not allow empty code blocks?

2016-08-03 Thread BartC
On 04/08/2016 00:25, Paul Rubin wrote: BartC writes: sometimes you try to find a .py import module and it doesn't seem to exist anywhere. (sys.py for example). I would like to see how such references are translated to Lisp. (require 'sys) What does that do? Don't tell me

Re: Why not allow empty code blocks?

2016-08-03 Thread BartC
On 03/08/2016 23:31, Chris Angelico wrote: On Thu, Aug 4, 2016 at 8:21 AM, BartC wrote: But is this a generic mechanism that works for /any/ .dll file, or does there have to be dedicated support for each of the 60 built-in modules? I'm talking about the former. Frankly, I don't

Re: Debugging (was Re: Why not allow empty code blocks?)

2016-08-04 Thread BartC
On 04/08/2016 04:23, Steven D'Aprano wrote: On Wed, 3 Aug 2016 08:16 pm, BartC wrote: So the idea that remembering 'repeat N' is a cognitive burden, and the myriad string operations for example are not, is ridiculous. Who says it isn't a cognitive burden? Of course it is

Re: Win32 API in pywin32

2016-08-05 Thread BartC
refers to both 32-bit and 64-bit APIs. Apart from which, Win64 will still run 32-bit applications. -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Python slang

2016-08-06 Thread BartC
rogramming languages use English keywords. It's more like why US English uses words like "windshield", "hood" and "trunk" instead of the proper "windscreen", "bonnet" and "boot". Oddly, for all its dynamism, Python doesn't allow aliases for its keywords to allow for personal taste. -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Python and 64bit Windows7

2016-08-08 Thread BartC
ariable 'belongs' to this command window and may not be seen by PyCharm if started from elsewhere. Setting it more globally is fiddly but there is plenty of info out there. The problem could be something else of course...) -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Postfix conditionals

2014-02-03 Thread BartC
ds for switch - one idea is to use an if-elseif chain, but that's just what it tries to avoid. Switch is attractive for an interpreted language because - provided all cases are constants, a bit of a problem in Python, because as soon as you give a name to something, it's no longer consta

Re: Postfix conditionals

2014-02-04 Thread BartC
"GöktuğKayaalp" wrote in message news:mailman.6377.1391490975.18130.python-l...@python.org... "BartC" writes: "Göktuğ Kayaalp" wrote in message news:mailman.4966.1388953508.18130.python-l...@python.org... AFAIK, we do not have "postfix conditionals"

Re: What is a function parameter =[] for?

2015-11-24 Thread BartC
h (perhaps not for just 3 elements). -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread BartC
ple or a list, or something else entirely (my date example above I think needs to be a class in Python, so that's a third way of doing things. Plus there is something called a 'set' that I haven't played with yet). > or use something else. Python isn't as bad as some

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread BartC
pecially they don't have the truly bizarre one that a function definition is itself a piece of code that is executed. Or maybe not executed, if it's inside a conditional statement! And therefore does not exist. This is an extra hurdle with learning or even using this language. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread BartC
On 25/11/2015 13:06, Marko Rauhamaa wrote: BartC : Then, from the point of view of a beginner, you have two distinct ways of representing a list of objects: a tuple and a list. Exactly why there have to be two is never really made clear beyond the inadequate explanation that one is immutable

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread BartC
On 25/11/2015 13:53, Marko Rauhamaa wrote: BartC : Using tuples in the same way that other languages implement records is going to be difficult if you can't change the values of the fields! Guido could decide tomorrow that tuples are mutable. (Could that be done without breaking exi

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread BartC
On 25/11/2015 15:13, Ned Batchelder wrote: On Wednesday, November 25, 2015 at 8:20:59 AM UTC-5, BartC wrote: Accept that some things /are/ a source of confusion. When, in writing documentation, I find something hard to explain something, then I try and make it simpler in the program. But not

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread BartC
On 25/11/2015 18:03, Ian Kelly wrote: On Wed, Nov 25, 2015 at 10:18 AM, BartC wrote: We have no way of evaluating their power or simplicity, since they are not available to us. I'll see if I can rustle up a comparison so that Python users can see what they're missing! Unless yo

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread BartC
On 25/11/2015 20:50, Mark Lawrence wrote: On 25/11/2015 17:18, BartC wrote: Can you please let us know what you're taking, what it costs and where we can get it, as we would also like to live in cloud cuckoo land, provided that The Price Is Right™. And I would really like to know what

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread BartC
On 25/11/2015 22:16, Marko Rauhamaa wrote: BartC : I'm interested in language design because that's what I've done on and off for over 30 years. And I'm discussing some design decisions in Python. That *is* a fun ambition, useful or not. (At the moment, it's most

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread BartC
On 26/11/2015 00:31, Steven D'Aprano wrote: On Thu, 26 Nov 2015 09:41 am, BartC wrote: Maybe you're too familiar with it. But the idea of executing the function and other definitions in a file, instead of they just being there, is novel. It really, truly isn't. Your viewpoin

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread BartC
On 26/11/2015 01:52, Ned Batchelder wrote: On Wednesday, November 25, 2015 at 8:23:36 PM UTC-5, BartC wrote: On 26/11/2015 00:31, Steven D'Aprano wrote: It really, truly isn't. Your viewpoint is clouded by too much immersion in crippled languages. *Old and obsolete versions* o

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread BartC
On 26/11/2015 13:15, Chris Angelico wrote: On Thu, Nov 26, 2015 at 11:53 PM, BartC wrote: FWIW here is that list of features that are different between Python and my language, or that work a different way, or that I think could be a useful addition. (Although Python's internal workings

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread BartC
On 26/11/2015 13:15, Chris Angelico wrote: On Thu, Nov 26, 2015 at 11:53 PM, BartC wrote: http://pastebin.com/JrVTher6 #14 and #15: Are you assuming that a character is a byte and that diacritical-free English is the only language in the world? I don't think that need be the assum

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread BartC
ange your mind. In fairness to BartC, I don't think that's malicious or trolling. I think it is as pure an example of what Paul Graham calls the Blub Paradox as I've ever seen. "Well, PaulGraham has a very (very) low opinion of OO, mostly because he does a lot of stuff that mos

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-27 Thread BartC
On 27/11/2015 01:09, Steven D'Aprano wrote: On Thu, 26 Nov 2015 12:23 pm, BartC wrote: [First-class functions] The names are declared, but the names are rarely bound to anything else. Functions are just called the same boring way they are in C. /They might as well be static defini

Re: static variables

2015-11-30 Thread BartC
On 30/11/2015 17:15, Ulli Horlacher wrote: def main(): a(1) a(2) a() print(a.x) if 'a.x' in globals(): print('global variable') if 'a.x' in locals(): print('local variable') Try this: if 'x' in a.__dict__: print(

Re: how to make the below code look better

2015-12-02 Thread BartC
compare_results() except Exception, e: logging.error(e) sys.exit("Comparing result failed") -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: increment/decrement operators

2015-12-05 Thread BartC
tatements, then why not simply map them to x+=1? In Python, that would need to be x++ and x-- as ++x or --x have existing meanings. -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Calling a list of functions

2015-12-13 Thread BartC
t2(): print "two" def print3(): print "three" print_test = [print1,print2,print3] #NOT calling the function for test in range(len(print_test)): try: print_test[test]() #calling the function except AssertionError: pass The output of t

Re: Why my image is in bad quality ?

2015-12-16 Thread BartC
s, or you've inadvertently applied a 'shear' or 'slant' transformation. (Maybe you can apply a reverse transform to fix it!) -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Why my image is in bad quality ?

2015-12-16 Thread BartC
On 16/12/2015 21:53, fsn761...@gmail.com wrote: On Thursday, December 17, 2015 at 1:36:55 AM UTC+4, BartC wrote: You need to test step by step to see at what point it goes wrong. You're scaling by 20 (which is a massive amount); what happens when scaling by 1? And anti-alias is turne

Re: Stop writing Python 4 incompatible code

2016-01-13 Thread BartC
went tried PyPy. Using range in 2.7 instead of xrange didn't make much difference either.) -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Stop writing Python 4 incompatible code

2016-01-13 Thread BartC
On 14/01/2016 01:21, Chris Angelico wrote: On Thu, Jan 14, 2016 at 12:02 PM, BartC wrote: I was surprised recently by just how much incompatibility there was between Python 2 and 3. It wasn't just about print with parentheses and range instead of xrange. I wanted to try out a jpeg de

Re: Writing a stream of bytes

2016-01-15 Thread BartC
7;>4B', *[1,2,3,4])) I always end up with the following bytes on file: !hexdump toto 000 0201 0403 Why is the hex dump doing 16-bits at a time? Get a byte dump, then it might actually be the right output. Anyway, this seems to work: data=bytearray([1,2,3,4]) f = open("output"

Re: Keen eyes

2016-01-17 Thread BartC
h with the name of a local, and screw things up. Because of that, the Python scheme is better on the whole. The only issue is that sometimes you think you're assigning to a global, but it's really a local if you forget the 'global' declaration within the function. -- Ba

Re: Considering migrating to Python from Visual Basic 6 for engineering applications

2016-02-18 Thread BartC
"But what if we pass the source code through a system that strips out leading whitespace?" "Then don't do that. What if you pass the source code through a system that strips out braces?" Python doesn't use braces, so that's not a problem! -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Considering migrating to Python from Visual Basic 6 for engineering applications

2016-02-19 Thread BartC
e, you can't do much about it, you just need to be aware of it. -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Considering migrating to Python from Visual Basic 6 for engineering applications

2016-02-19 Thread BartC
On 19/02/2016 15:59, Grant Edwards wrote: On 2016-02-19, BartC wrote: On 17/02/2016 19:49, wrong.addres...@gmail.com wrote: Could someone kindly tell me advantages and disadvantages of Python? Something I don't think anyone has mentioned is that Python is case-sensitive. That

Re: Considering migrating to Python from Visual Basic 6 for engineering applications

2016-02-19 Thread BartC
tically typed, so the language knows what types to read into each of those variables. And the Fortran might have a 'format' to help out, unless they've got rid of those since 1979...) -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Considering migrating to Python from Visual Basic 6 for engineering applications

2016-02-21 Thread BartC
a particular set of types is to imposed on the input.) In other words, it seems this particular wheel does require re-inventing! -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Considering migrating to Python from Visual Basic 6 for engineering applications

2016-02-21 Thread BartC
On 21/02/2016 15:08, Jussi Piitulainen wrote: BartC writes: In other words, it seems this particular wheel does require re-inventing! It's hardly Python's problem if an engineer is worried about some VB not being there in its current form in the future. The sample code upthr

Re: Considering migrating to Python from Visual Basic 6 for engineering applications

2016-02-21 Thread BartC
On 21/02/2016 21:52, Jussi Piitulainen wrote: BartC writes: But this is not so much to do with VB6, but with a very fundamental capability that seems missing in modern languages. All that's missing is a minor convenience that turns out to be mainly awkward. Not at all fundamental. I

Re: Considering migrating to Python from Visual Basic 6 for engineering applications

2016-02-22 Thread BartC
On 22/02/2016 08:50, Jussi Piitulainen wrote: BartC writes: Reading stuff from an interactive console or terminal, is such an important part of the history of computing, still being used now, that you'd think a language would provide simple, ready-to-use methods ways to do it. I thi

Re: Considering migrating to Python from Visual Basic 6 for engineering applications

2016-02-22 Thread BartC
On 22/02/2016 11:16, Steven D'Aprano wrote: On Mon, 22 Feb 2016 12:16 am, BartC wrote: [...] No need for anyone to re-invent the wheel! ;-) I keep seeing this in the thread. Python has all this capability, yet it still requires a lot of fiddly code to be added to get anywhere near as s

Re: Considering migrating to Python from Visual Basic 6 for engineering applications

2016-02-22 Thread BartC
On 22/02/2016 10:46, Steven D'Aprano wrote: On Mon, 22 Feb 2016 08:52 am, Jussi Piitulainen wrote: BartC writes: IIRC, the first programming exercise I ever did (in 1976 using Algol 60) involved reading 3 numbers from the teletype and working out if those could form sides of a tri

Re: Everything good about Python except GUI IDE?

2016-02-27 Thread BartC
es (which would be the stumbling block for me), then a few hundred lines of script code isn't a lot. And Python is a scripting language. And once one form or part of one is done, you might able to just copy and adapt the code instead of having to write everything from scratch.

Re: How to read from a file to an arbitrary delimiter efficiently?

2016-02-27 Thread BartC
e using only fgetc(), compared with any buffered solutions.) -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: How to read from a file to an arbitrary delimiter efficiently?

2016-02-27 Thread BartC
On 27/02/2016 16:35, BartC wrote: On 25/02/2016 06:50, Steven D'Aprano wrote: I have a need to read to an arbitrary delimiter, which might be any of a (small) set of characters. For the sake of the exercise, lets say it is either ! or ? (for example). However those aren't the ma

Re: How to read from a file to an arbitrary delimiter efficiently?

2016-02-27 Thread BartC
On 27/02/2016 20:03, BartC wrote: On 27/02/2016 16:35, BartC wrote: Any faster solutions would need to read more than one byte at a time. I've done some more test using Python 3.4, with the same 200,000 line 6MB test file: 0.25 seconds Scan the file with 'for line in f

Re: Everything good about Python except GUI IDE?

2016-02-28 Thread BartC
exact subcategory, size, quantity... -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Everything good about Python except GUI IDE?

2016-02-28 Thread BartC
On 28/02/2016 12:54, Rustom Mody wrote: On Sunday, February 28, 2016 at 6:08:44 PM UTC+5:30, BartC wrote: You have to give someone some shopping to do. What's quicker, jotting down a list of milk, bread, eggs and so on, or invoking some GUI program where you have to first look for

Re: Everything good about Python except GUI IDE?

2016-02-28 Thread BartC
et start typing on a now blank document, and it's still the wrong style! That's what I mean by these applications having minds of their own. And with a 300-page document you can't just start all over, you need something reliable, and not so smart.) -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Everything good about Python except GUI IDE?

2016-02-29 Thread BartC
On 29/02/2016 00:49, Steven D'Aprano wrote: On Mon, 29 Feb 2016 01:29 am, BartC wrote: 20 years ago, when these things were simpler, MS Word had a mind of its own even then. I had to produce a manual of few hundred pages, with diagrams and images, and it just wasn't going to h

Re: Reason for not allowing import twice but allowing reload()

2016-02-29 Thread BartC
;t think of enough uses for it. -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Phyton

2016-03-06 Thread BartC
/docs.python.org/2/tutorial/controlflow.html Your example would become something like: salary = 1250. if salary > 1200: has_to_pay_tax = True else: has_to_pay_tax = False The OP mentioned finding an expression. So perhaps: has_to_pay_tax = salary > 1200 -- Bartc -- https:/

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-07 Thread BartC
d with MSVC not gcc. But it would affect 2 and 3 equally.) ([2] With larger data, PyPy gets progressively faster compared with normal Python, as it can optimise big loops better. This test was with 0.5 Mpixels of data) -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-07 Thread BartC
On 07/03/2016 11:11, Marko Rauhamaa wrote: BartC : I've also found that 3 was consistently slower than 2 on various benchmarks. Perhaps 10 to 20% slower (also 3.4 vs. 2.7). Python doesn't exist for performance-critical parts of your solution. Also, Python programs tend to take hu

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-07 Thread BartC
On 07/03/2016 12:19, Fabien wrote: On 03/07/2016 12:38 PM, BartC wrote: (Although competing with CPython is too easy. PyPy is more of a problem. With the Jpeg benchmark I mentioned, I can beat PyPy up to 6Mpix, but then PyPy starts to get faster. At 80Mpix, PyPy is 60% faster.) Just out of

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-07 Thread BartC
On 07/03/2016 15:31, Chris Angelico wrote: On Tue, Mar 8, 2016 at 12:25 AM, BartC wrote: (The Python version of that program is here: http://pastebin.com/cHx3UhQb. It should work with any Python.) Actually, it won't work with any Python - not if it gets a broken file. Your abor

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-07 Thread BartC
On 07/03/2016 19:10, Chris Angelico wrote: On Tue, Mar 8, 2016 at 5:34 AM, BartC wrote: def abortjpeg(mess): print ("Error:",mess) raise Here's my Python: RuntimeError: No active exception to reraise OK I'll have a look. (Or maybe just change 'rai

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-07 Thread BartC
On 07/03/2016 20:47, Chris Angelico wrote: On Tue, Mar 8, 2016 at 7:19 AM, BartC wrote: What can be more perfect for comparing two implementations? rosuav@sikorsky:~$ python2 -m timeit -s 'from fp import Float' 'Float("1234.567")' 100 loops, best o

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-07 Thread BartC
On 07/03/2016 23:40, Chris Angelico wrote: On Tue, Mar 8, 2016 at 9:39 AM, BartC wrote: I'm using it because this kind of file reading in Python is a mess. If I do a read, will I get a string, a byte sequence object, a byte-array, or array-array, or what? Uhh you'll get eit

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-07 Thread BartC
On 08/03/2016 00:05, Ben Finney wrote: BartC writes: On 07/03/2016 20:47, Chris Angelico wrote: Look! Creating a floating-point value is faster under Python 2 than Python 3. What could be more perfect? This is like a microbenchmark in that it doesn't tell you anything about real-

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-07 Thread BartC
On 08/03/2016 01:23, Chris Angelico wrote: On Tue, Mar 8, 2016 at 12:00 PM, BartC wrote: Yes of course it does. As does 'being slow'. Take another microbenchmark: def whiletest(): | i=0 | while i<=1: | | i+=1 whiletest() Python 2.7: 8.4 seconds Python 3.1:

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-07 Thread BartC
On 08/03/2016 01:19, Steven D'Aprano wrote: On Tue, 8 Mar 2016 07:19 am, BartC wrote: I don't have to hand a jpeg file that it can't decode. Run this under Python 2: from random import randint blob = [randint(0, 256) for i in range(16*1024)] with open('bro

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-07 Thread BartC
On 08/03/2016 01:12, Mark Lawrence wrote: On 08/03/2016 01:00, BartC wrote: If your efforts manage to double the speed of reading file A, then probably the reading file B is also going to be improved! In practice you use a variety of files, but one at a time will do. What is the difference

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-07 Thread BartC
On 08/03/2016 01:40, Chris Angelico wrote: On Tue, Mar 8, 2016 at 12:33 PM, BartC wrote: Let me ask you a follow-on question first: how slow does a new Python version have to be before even you would take notice? Compared with 2.7, 3.4 above is spending nearly an extra ten seconds doing

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-08 Thread BartC
On 08/03/2016 02:45, Mark Lawrence wrote: On 08/03/2016 01:47, BartC wrote: The Python timing for that file is around 20 seconds, time enough to read 1 copies from the disk. And a C program reads /and decodes/ the same file from the same disk in between 0.1 and 0.2 seconds. So how

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-08 Thread BartC
On 08/03/2016 02:47, MRAB wrote: On 2016-03-08 01:33, BartC wrote: Compared with 2.7, 3.4 above is spending nearly an extra ten seconds doing what? I can't understand why someone just wouldn't care. Part of it will be that Python 2 has 2 integer types: 'int' (fix

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-08 Thread BartC
On 08/03/2016 02:12, Steven D'Aprano wrote: On Tue, 8 Mar 2016 09:39 am, BartC wrote: I'm using it because this kind of file reading in Python is a mess. If I do a read, will I get a string, a byte sequence object, a byte-array, or array-array, or what? Calling it &quo

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-08 Thread BartC
On 08/03/2016 11:45, Jussi Piitulainen wrote: BartC writes: On 08/03/2016 02:47, MRAB wrote: On 2016-03-08 01:33, BartC wrote: Compared with 2.7, 3.4 above is spending nearly an extra ten seconds doing what? I can't understand why someone just wouldn't care. Part of it wi

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-08 Thread BartC
On 08/03/2016 04:40, Steven D'Aprano wrote: On Tuesday 08 March 2016 12:41, BartC wrote: On 08/03/2016 01:19, Steven D'Aprano wrote: On Tue, 8 Mar 2016 07:19 am, BartC wrote: I don't have to hand a jpeg file that it can't decode. Run this under Python 2: from random

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-08 Thread BartC
On 08/03/2016 16:15, Mark Lawrence wrote: On 08/03/2016 13:49, BartC wrote: On 08/03/2016 04:40, Steven D'Aprano wrote: On Tuesday 08 March 2016 12:41, BartC wrote: Nevertheless, in the real world, you have to deal with corrupt JPGs and files mislabelled as JPGs. And "crashing"

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-08 Thread BartC
On 08/03/2016 16:09, Mark Lawrence wrote: On 08/03/2016 11:09, BartC wrote: On 08/03/2016 02:45, Mark Lawrence wrote: On 08/03/2016 01:47, BartC wrote: The Python timing for that file is around 20 seconds, time enough to read 1 copies from the disk. And a C program reads /and decodes

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-08 Thread BartC
On 08/03/2016 20:44, Mark Lawrence wrote: On 08/03/2016 19:15, BartC wrote: Surely the start-up time would be the same no matter what the input. Unless all of the background jobs are kicking in when you're testing. I assume that you do take such factors into account, by repeating

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-08 Thread BartC
On 08/03/2016 23:28, Steven D'Aprano wrote: On Tue, 8 Mar 2016 10:53 pm, BartC wrote: Python 2 Python 3 Text mode 'str' 'str' Binary mode 'bytes''str' That table is incorrect. In Python 2, bytes is just

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-08 Thread BartC
On 09/03/2016 00:04, Steven D'Aprano wrote: On Wed, 9 Mar 2016 12:49 am, BartC wrote: Nevertheless, in the real world, you have to deal with corrupt JPGs and files mislabelled as JPGs. And "crashing" doesn't count as "deal with" :-) OK, I changed the '

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-09 Thread BartC
On 09/03/2016 08:40, Mark Lawrence wrote: On 08/03/2016 23:59, Steven D'Aprano wrote: On Wed, 9 Mar 2016 06:15 am, BartC wrote: [...] But this was hardly necessary as it was so obvious: it takes 150ms to process a 300-pixel image, 20 seconds for a 2Mpixel one, and (I have to switch to

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-09 Thread BartC
On 09/03/2016 02:18, Steven D'Aprano wrote: On Wed, 9 Mar 2016 12:28 pm, BartC wrote: (Which wasn't as painful as I'd expected. However the next project I have in mind is 20K lines rather than 0.7K. For that I'm looking at some mechanical translation I think. And probably

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-09 Thread BartC
On 09/03/2016 14:11, Chris Angelico wrote: On Thu, Mar 10, 2016 at 1:03 AM, BartC wrote: I've just tried a UTF-8 file and getting some odd results. With a file containing [three euro symbols]: €€€ (including a 3-byte utf-8 marker at the start), and opened in text mode, Python 3 gives me

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-09 Thread BartC
to use to use the same directory it's just loaded a file from as a default. But it does have a reasonable choice of output encodings.) -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-09 Thread BartC
On 09/03/2016 21:13, Mark Lawrence wrote: On 09/03/2016 12:02, BartC wrote: On 09/03/2016 08:40, Mark Lawrence wrote: Here's another: you have a program in Python that you'd quite like to port to another dynamic language. Transcribing actual Python code is straightforward. Until you

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-09 Thread BartC
On 09/03/2016 23:35, Mark Lawrence wrote: On 09/03/2016 23:14, BartC wrote: (The byte-code compiler for the current version is written in itself. It can compile itself (some 25Kloc) in about 1 second (that's running interpreted, dynamic byte-code on a not-very-fast PC). Please answ

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-09 Thread BartC
On 09/03/2016 23:38, Chris Angelico wrote: On Thu, Mar 10, 2016 at 10:14 AM, BartC wrote: program to be actually written in Python. Sometimes you want to understand how code works or what it does or simply to learn from it. (Or sometimes, to rip bits off.) Then it's frustrating when you

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-10 Thread BartC
On 10/03/2016 07:30, Mark Lawrence wrote: On 10/03/2016 00:58, BartC wrote: You think a bloody great compiler is a microbenchmark?! I have no interest in the speed of the compiler, I am interested in the run time speed of the applications that it produces which is what has been discussed

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-10 Thread BartC
terest because there were some parallels with the script language I was using for my applications (I decided my language needed byte-arrays bolted on; Python also added byte-arrays!) Python however decided to be far more dynamic. (Making efficient interpreters a bit harder to write.) -- Bartc

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-10 Thread BartC
On 10/03/2016 12:15, Mark Lawrence wrote: On 10/03/2016 11:50, BartC wrote: Suppose you were on the development team that writes the optimising stages of a C compiler. You need to test the performance of the code it produces so that you can compare one optimisation with another. Would you

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-10 Thread BartC
On 10/03/2016 13:08, Chris Angelico wrote: On Thu, Mar 10, 2016 at 11:47 PM, BartC wrote: You just don't get it. Both of you "just don't get" something that the other sees as critically important. Before this thread gets to fisticuffs, may I please summarize the points

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-10 Thread BartC
On 10/03/2016 02:29, Ben Finney wrote: BartC writes: So long as /someone else/ uses the hard language to created the needed libraries, the speed of pure Python is irrelevant. New version of Python is now half the speed? Another shrug! Citation needed. I don't know of any released ve

Re: Review Request of Python Code

2016-03-10 Thread BartC
actually takes that long. -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Simple exercise

2016-03-10 Thread BartC
t(parts)) # 'banana fries' try: n = names.index(name) # update existing entry totals[n] += value except: names.append(name) # new entry totals.append(value) for i in range(len(names)): print (names[i],totals[i]) -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Simple exercise

2016-03-10 Thread BartC
On 11/03/2016 01:21, Mark Lawrence wrote: On 11/03/2016 00:05, BartC wrote: def last(a): return a[-1] def init(a): # all except last element return a[0:len(a)-1] What is wrong with a[0:1] ? The returns the head of the list. I need everything except the last

Re: Simple exercise

2016-03-10 Thread BartC
On 11/03/2016 02:03, Mark Lawrence wrote: On 11/03/2016 01:45, BartC wrote: On 11/03/2016 01:21, Mark Lawrence wrote: On 11/03/2016 00:05, BartC wrote: def last(a): return a[-1] def init(a): # all except last element return a[0:len(a)-1] What is wrong with a[0:1

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-11 Thread BartC
is project seems to! (Mine would be to design the language to be less dynamic in the first place.) -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-11 Thread BartC
On 11/03/2016 21:59, Mark Lawrence wrote: On 11/03/2016 18:57, BartC wrote: def test(): s="" for i in range(1000): s+="*" print (len(s)) test() The minor snag that you might like to correct with your microbenchmark, which any experienced Pyt

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-11 Thread BartC
On 11/03/2016 21:36, Chris Angelico wrote: On Sat, Mar 12, 2016 at 5:57 AM, BartC wrote: Functions are dynamic. That is, you don't know the F in F() is actually a function, even if it was defined a few lines previously, because it could have been rebound to something else. That me

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-12 Thread BartC
On 12/03/2016 10:06, alister wrote: On Fri, 11 Mar 2016 22:24:45 +, BartC wrote: On 11/03/2016 21:59, Mark Lawrence wrote: On 11/03/2016 18:57, BartC wrote: def test(): s="" for i in range(1000): s+="*" print (len(s)) test() The

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-12 Thread BartC
On 12/03/2016 01:15, Michael Torrie wrote: On 03/11/2016 03:24 PM, BartC wrote: On 11/03/2016 21:59, Mark Lawrence wrote: On 11/03/2016 18:57, BartC wrote: def test(): s="" for i in range(1000): s+="*" print (len(s)) test() The minor

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-12 Thread BartC
TION 1 You might be right: doing an unnecessary global name lookup and executing a function call are unlikely to have any impact on performance... The problem here is that 'ord' is dynamic, so this operation cannot simply be done at compile-time. Even when you try and optimise by a

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-12 Thread BartC
On 12/03/2016 02:20, Chris Angelico wrote: On Sat, Mar 12, 2016 at 12:16 PM, BartC wrote: 'Switch' testing benchmark. The little program show below reads a text file (I used the entire CPython C sources, 6MB), and counts the number of characters of each category in upper, lower,

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-12 Thread BartC
On 12/03/2016 12:13, Marko Rauhamaa wrote: BartC : If you're looking at fast processing of language source code (in a thread partly about efficiency), then you cannot ignore the fact that the vast majority of characters being processed are going to have ASCII codes. I don't kn

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-12 Thread BartC
On 12/03/2016 11:51, Marko Rauhamaa wrote: BartC : What's big deal with dynamism anyway? I could never understand Python's obsession with it. For me, 'dynamic' means that a variable has a dynamic type; that's all. But you know at compile-time (or when looking at sourc

<    2   3   4   5   6   7   8   9   10   11   >