Re: List replication operator

2018-05-25 Thread bartc
)) print (len(x[0])) print (len(x[0][0])) Gives output of 4, 3, 2 rather than 2, 3, 4. Which means that x[0][0][3] is a bounds error. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: List replication operator

2018-05-25 Thread bartc
On 25/05/2018 17:11, Alexandre Brault wrote: On 2018-05-25 11:40 AM, bartc wrote: On 25/05/2018 16:27, Chris Angelico wrote: You're way WAY too late to debate the matrix multiplication operator. /The/ matrix multiplication operator? In which language? And what was wrong

Re: List replication operator

2018-05-25 Thread bartc
On 25/05/2018 16:40, Steven D'Aprano wrote: On Fri, 25 May 2018 22:46:37 +1000, Chris Angelico wrote: We've already had a suggestion for [[]]@5 and that should deal with that issue. Steven is proposing "multiply by copying" as an alternative to "multiply by referencing", so an alternative

Re: List replication operator

2018-05-25 Thread bartc
On 25/05/2018 16:27, Chris Angelico wrote: On Fri, May 25, 2018 at 10:58 PM, bartc <b...@freeuk.com> wrote: I'm in general not in favour of piling in special symbols into a language just to solve some obscure or rare problem. As I went on to demonstrate, function-like syntax (or even

Re: List replication operator

2018-05-25 Thread bartc
On 25/05/2018 13:46, Chris Angelico wrote: On Fri, May 25, 2018 at 10:36 PM, bartc <b...@freeuk.com> wrote: On 24/05/2018 19:17, Steven D'Aprano wrote: But what do people think about proposing a new list replication with copy operator? [[]]**5 would return a new list cons

Re: List replication operator

2018-05-25 Thread bartc
On 25/05/2018 13:36, bartc wrote: Of course you have to implement dupllist(), but you'd have to implement ** too, and that is harder. For this specific example, it can just be: def dupllist(x,n):     return [x[0].copy() for _ in range(n)] On 25/05/2018 03:25, Steven D'Aprano wrote: >

Re: List replication operator

2018-05-25 Thread bartc
, and that is harder. For this specific example, it can just be: def dupllist(x,n): return [x[0].copy() for _ in range(n)] -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: why do I get syntax error on if : break

2018-05-25 Thread bartc
On 25/05/2018 11:08, asa32s...@gmail.com wrote: On Thursday, May 24, 2018 at 10:12:46 PM UTC-4, asa3...@gmail.com wrote: here is the code, i keep getting an error, "break outside loop". if it is false just exit function def d(idx): if type(idx) != int: break d('k') thanks...

Re: Raw string statement (proposal)

2018-05-25 Thread bartc
m inclined not to make it part of the language at all, but to make it an editor feature: insert a block of arbitrary text, and give a command to turn it into a string literal. With perhaps another command to take a string literal within a program and view it as un-escaped text. -- bartc -- https://ma

Re: how to get INDEX count, or last number of Index

2018-05-24 Thread bartc
On 24/05/2018 03:37, Terry Reedy wrote: On 5/23/2018 8:46 PM, bartc wrote: On 24/05/2018 00:44, Terry Reedy wrote: On 5/23/2018 5:56 PM, Rob Gaddi wrote: On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread bartc
On 24/05/2018 01:46, bartc wrote: On 24/05/2018 00:44, Terry Reedy wrote: On 5/23/2018 5:56 PM, Rob Gaddi wrote: On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, Use -1, which is the same a

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread bartc
self which would be 'i'. And actually, the subject line seems to confirm that. In that case, using a '-1' index won't work. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread bartc
On 23/05/2018 22:51, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, but i assume there is a function that gives me last number of index Not for that trivial task. But you can create your own: def upb(x): return len(x)-1 #

Re: "Data blocks" syntax specification draft

2018-05-23 Thread bartc
comprises, then you will run into problems. Try adding two tuples: 1, 2, 3 + 4, 5, 6 This in fact gives you 1,2,7,5,6 rather than 5,7,9. (I don't know if tuples can actually be added like this, but the point is clear.) -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: "Data blocks" syntax specification draft

2018-05-23 Thread bartc
On 23/05/2018 14:11, Steven D'Aprano wrote: On Wed, 23 May 2018 11:10:33 +0100, bartc wrote: (x,) Tuple of one item Incorrect. Yet again, you have failed to do enough testing. No special form is required. Only a comma: py> x = 1, py> type(x) It isn't enough to test examples which c

Re: "Data blocks" syntax specification draft

2018-05-23 Thread bartc
of them are tied to anything to do with tuples. Actually 'tuple' doesn't appear at all. 'dict' does, presumably because a dict-constructor is different syntactically in requiring key:value pairs. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: "Data blocks" syntax specification draft

2018-05-23 Thread bartc
On 23/05/2018 07:47, Steven D'Aprano wrote: On Tue, 22 May 2018 18:51:30 +0100, bartc wrote: On 22/05/2018 15:25, Chris Angelico wrote: [...] The tuple has nothing to do with the parentheses, except for the special case of the empty tuple. It's the comma. No? Take these: a = (10,20,30

Re: "Data blocks" syntax specification draft

2018-05-22 Thread bartc
quite right either. Asterisk is just an overloaded token but you will what it's for as soon as it's encountered. Comma seems to be used only as a separator. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: "Data blocks" syntax specification draft

2018-05-22 Thread bartc
On 22/05/2018 15:25, Chris Angelico wrote: On Tue, May 22, 2018 at 8:25 PM, bartc <b...@freeuk.com> wrote: Note that Python tuples don't always need a start symbol: a = 10,20,30 assigns a tuple to a. The tuple has nothing to do with the parentheses, except for the specia

Re: "Data blocks" syntax specification draft

2018-05-22 Thread bartc
On 22/05/2018 03:49, Mikhail V wrote: On Mon, May 21, 2018 at 3:48 PM, bartc <b...@freeuk.com> wrote: But I have to say it looks pretty terrible, and I can't see that it buys much over normal syntax. # t # t 11 22 33 Is this example complete? Presumably it means ((11

Re: "Data blocks" syntax specification draft

2018-05-21 Thread bartc
ut you need: date = \ /// Or do you also allow: date = /// with data following on the next line? -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: "Data blocks" syntax specification draft

2018-05-21 Thread bartc
ia PDF; I doubt airlines wanted to alienate Linux users). -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: what does := means simply?

2018-05-20 Thread bartc
On 20/05/2018 16:37, Dennis Lee Bieber wrote: On Sun, 20 May 2018 12:38:59 +0100, bartc <b...@freeuk.com> declaimed the Just for giggles, I decided to write the start of a PPM reader (it only handles P6 binary, doesn't have the code for the other styles, and doesn't incorpora

Re: what does := means simply?

2018-05-20 Thread bartc
On 20/05/2018 10:19, Peter J. Holzer wrote: On 2018-05-19 13:43:14 +0100, bartc wrote: Text files, yes. Not 'text mode' which is something inflicted on us by the C library. I very much enjoy the fact that the programming languages I've used to process text files in the last 15 years (i.e

Re: what does := means simply?

2018-05-20 Thread bartc
On 20/05/2018 02:58, Dennis Lee Bieber wrote: On Sun, 20 May 2018 02:13:01 +0100, bartc <b...@freeuk.com> declaimed the following: I think if you are going to be generating ppm, then the best choice of format, for the widest acceptance, is to separate the header groups with a newline.

Re: what does := means simply?

2018-05-19 Thread bartc
On 20/05/2018 01:39, Dennis Lee Bieber wrote: On Sat, 19 May 2018 23:14:08 +0100, bartc <b...@freeuk.com> declaimed the following: The comments and examples here: https://en.wikipedia.org/wiki/Netpbm_format, and all actual ppm files I've come across, suggest the 3 parts of the header (2

Re: what does := means simply?

2018-05-19 Thread bartc
On 19/05/2018 20:47, Dennis Lee Bieber wrote: On Sat, 19 May 2018 13:28:41 +0100, bartc <b...@freeuk.com> declaimed the following: Out of interest, how would Python handle the headers for binary file formats P4, P5, P6? I'd have a go but I don't want to waste half the day trying to ge

Re: what does := means simply?

2018-05-19 Thread bartc
On 19/05/2018 12:33, Peter J. Holzer wrote: On 2018-05-19 11:33:26 +0100, bartc wrote: Not you understand why some of us don't bother with 'text mode' files. "Not" or "Now"? Now. Yesterday you claimed that you worked with them for 40 years. Text files, yes. N

Re: what does := means simply?

2018-05-19 Thread bartc
On 19/05/2018 12:38, Chris Angelico wrote: On Sat, May 19, 2018 at 8:33 PM, bartc <b...@freeuk.com> wrote: But then you are acknowledging the file is, in fact, ASCII. Cool! So what happens if you acknowledge that a file is ASCII, and then it starts with a byte value of E3 ? It d

Re: what does := means simply?

2018-05-19 Thread bartc
On 19/05/2018 02:26, Chris Angelico wrote: On Sat, May 19, 2018 at 11:10 AM, bartc <b...@freeuk.com> wrote: The .ppm (really .pbm) file which was the subject of this sub-thread has its header defined using ASCII. I don't think an EBCDIC 'P4' etc will work. "Defined using ASCII&q

Re: what does := means simply?

2018-05-18 Thread bartc
.ppm (really .pbm) file which was the subject of this sub-thread has its header defined using ASCII. I don't think an EBCDIC 'P4' etc will work. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: what does := means simply?

2018-05-18 Thread bartc
On 19/05/2018 01:42, Dennis Lee Bieber wrote: On Fri, 18 May 2018 22:53:06 +0100, bartc <b...@freeuk.com> declaimed the following: I've worked with text files for 40 years. Now Python is telling me I've been doing it wrong all that time! Look at the original code I posted from

Re: what does := means simply?

2018-05-18 Thread bartc
On 19/05/2018 01:00, Chris Angelico wrote: On Sat, May 19, 2018 at 7:53 AM, bartc <b...@freeuk.com> wrote: I've worked with text files for 40 years. Now Python is telling me I've been doing it wrong all that time! Look at the original code I posted from which this Python was

Re: what does := means simply?

2018-05-18 Thread bartc
On 18/05/2018 19:57, Chris Angelico wrote: On Sat, May 19, 2018 at 4:48 AM, bartc <b...@freeuk.com> wrote: The translation was straightforward, EXCEPT that I wasted an hour trying to figure out to write /a single byte/ to a file. The following eventually worked, using a binary file as

Re: what does := means simply?

2018-05-18 Thread bartc
On 18/05/2018 20:15, Alexandre Brault wrote: On 2018-05-18 02:48 PM, bartc wrote: Note this version doesn't use any imports at all. Except your version doesn't read its parameter from the command line args and doesn't output to standard output, which all of the others do. That's why

Re: what does := means simply?

2018-05-18 Thread bartc
On 18/05/2018 19:36, Chris Angelico wrote: On Sat, May 19, 2018 at 3:27 AM, bartc <b...@freeuk.com> wrote: Once again, you're confusing *porting* with *emulating*. This is the point. Those libraries are specific to Python and cannot be ported. And very often they don't just p

Re: what does := means simply?

2018-05-18 Thread bartc
On 18/05/2018 18:27, bartc wrote: (BTW here's a port of that benchmark based on the Lua code:   https://pastebin.com/raw/ivDaKudX And here's the payoff: I was able to use this version to port it to Python. One which works better the the originals, as they wrote output to the screen

Re: what does := means simply?

2018-05-18 Thread bartc
On 18/05/2018 15:47, Chris Angelico wrote: On Sat, May 19, 2018 at 12:37 AM, bartc <b...@freeuk.com> wrote: Have a look at some of the implementations here (to test some Mandelbrot benchmark): https://benchmarksgame-team.pages.debian.net/benchmarksgame/performance/mandelbrot.html The

Re: what does := means simply?

2018-05-18 Thread bartc
On 18/05/2018 13:29, Steven D'Aprano wrote: On Fri, 18 May 2018 12:09:02 +0100, bartc wrote: On 18/05/2018 02:45, Steven D'Aprano wrote: On Fri, 18 May 2018 02:17:39 +0100, bartc wrote: Normally you'd use the source code as a start point. In the case of Python, that means Python source code

Re: syntax oddities

2018-05-18 Thread bartc
On 17/05/2018 23:49, Chris Angelico wrote: On Fri, May 18, 2018 at 8:44 AM, Paul wrote: I've been using email for thirty years, including thousands of group emails at many tech companies, and no one has ever suggested, let alone insisted on, bottom posting. If someone's

Re: what does := means simply?

2018-05-18 Thread bartc
On 18/05/2018 02:45, Steven D'Aprano wrote: On Fri, 18 May 2018 02:17:39 +0100, bartc wrote: Normally you'd use the source code as a start point. In the case of Python, that means Python source code. But you will quickly run into problems because you will often see 'import lib' and be unable

Re: what does := means simply?

2018-05-17 Thread bartc
On 17/05/2018 18:19, Steven D'Aprano wrote: On Thu, 17 May 2018 15:50:17 +0100, bartc wrote: Of course, full-on Python code is pretty much impossible to port anywhere else anyway. *rolls eyes* Any pair of languages will have code that is hard to port from one to the other without jumping

Re: what does := means simply?

2018-05-17 Thread bartc
On 17/05/2018 15:03, Chris Angelico wrote: On Thu, May 17, 2018 at 9:58 PM, bartc <b...@freeuk.com> wrote: On 17/05/2018 04:54, Steven D'Aprano wrote: On Thu, 17 May 2018 05:33:38 +0400, Abdur-Rahmaan Janhangeer wrote: what does := proposes to do? A simple example (not neces

Re: what does := means simply?

2018-05-17 Thread bartc
On 17/05/2018 14:32, Steven D'Aprano wrote: On Thu, 17 May 2018 12:58:43 +0100, bartc wrote: On 17/05/2018 04:54, Steven D'Aprano wrote: On Thu, 17 May 2018 05:33:38 +0400, Abdur-Rahmaan Janhangeer wrote: what does := proposes to do? A simple example (not necessarily a GOOD example

Re: what does := means simply?

2018-05-17 Thread bartc
it assumes left-to-right evaluation order of the arguments. Even if Python guarantees that, it might be a problem if the code is ever ported anywhere else. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-16 Thread bartc
On 16/05/2018 16:09, Ian Kelly wrote: On Tue, May 15, 2018, 6:36 PM bartc <b...@freeuk.com> wrote: On 16/05/2018 01:04, Steven D'Aprano wrote: I'm not a C coder, but I think that specific example would be immune to the bug we are discussing, since (I think) you can't chain assignment

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-15 Thread bartc
assignments (+= and so on). -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-15 Thread bartc
be an error in Python) because usually both = and == are plausible in an expression. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-12 Thread bartc
On 12/05/2018 05:29, Steven D'Aprano wrote: On Fri, 11 May 2018 16:56:09 +0100, bartc wrote: 0100, if not intended as octal, is an undetectable error in C and Python 2. How fortunate then that Python 2 is history (soon to be ancient history) and people can use Python 3 where that error

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-11 Thread bartc
On 11/05/2018 14:24, Chris Angelico wrote: On Fri, May 11, 2018 at 9:09 PM, bartc <b...@freeuk.com> wrote: when 101'11010'000'B then ... Try /that/ in hex /or/ octal.) I've no idea what this is supposed to mean, or why you have groups of three, five, and three. Looks like a po

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-11 Thread bartc
On 10/05/2018 21:18, bartc wrote: On 10/05/2018 19:51, Chris Angelico wrote: On Fri, May 11, 2018 at 4:31 AM, bartc <b...@freeuk.com> wrote:    2x100  (4)   Binary    3x100  (9)   Ternary    4x100  (16)  Quaternary    5x100  (25)  etc    6x100  (36)    7x100  (49)    8x100  (64) 

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-11 Thread bartc
On 11/05/2018 01:11, Chris Angelico wrote: On Fri, May 11, 2018 at 8:43 AM, bartc <b...@freeuk.com> wrote: This is Wrong, and would have been just as obviously wrong in 1989. Having spent many years programming in C and working on Unix, I strongly disagree. Using C is apt to gi

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-10 Thread bartc
t were multiples of three bits, or were divided up on 3-bit boundaries. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-10 Thread bartc
2629 miles This is Wrong, and would have been just as obviously wrong in 1989. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-10 Thread bartc
On 10/05/2018 19:51, Chris Angelico wrote: On Fri, May 11, 2018 at 4:31 AM, bartc <b...@freeuk.com> wrote: 2x100 (4) Binary 3x100 (9) Ternary 4x100 (16) Quaternary 5x100 (25) etc 6x100 (36) 7x100 (49) 8x100 (64) Octal 9x10

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-10 Thread bartc
On 10/05/2018 18:03, Ian Kelly wrote: On Thu, May 10, 2018 at 10:36 AM, bartc <b...@freeuk.com> wrote: What, 0O100 instead of 0100? Yeah that's a big improvement... Fortunately octal doesn't get used much. The PEP discusses this: """ Proposed syntaxes included things

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-10 Thread bartc
syntax that doesn't need to be backwards compatible. That changed in Python 3. If you slim the start of PEP 3127, you'll learn the new notation. What, 0O100 instead of 0100? Yeah that's a big improvement... Fortunately octal doesn't get used much. -- Bartc -- https://mail.python.org/mailman

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-10 Thread bartc
On 10/05/2018 09:09, Marko Rauhamaa wrote: bartc <b...@freeuk.com>: On 09/05/2018 06:44, Steven D'Aprano wrote: But by the time 1.4 came around, Guido had settled on a clean separation between statements and expressions as part of Python's design. That separation has gradually weakene

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-09 Thread bartc
nts in expressions, as it's not that useful, and it would be too much (and I could never get the precedences right). But normal assignment is handy.) -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Minmax tictactoe :c Cannot understand why this does not work

2018-04-25 Thread bartc
.) Is an empty movimientos allowed at this point or not? Is auxb==0 a legal index here or not? (Tip: I used these lines in the input loop to simply testing rather than having to type them in (as 2 and 2) each time: fila = 1 columna = 1 ) -- bartc -- https://mail.python.org/mailman/listinfo

Re: Issue with python365.chm on window 7

2018-04-24 Thread bartc
to say the least for a HELP file of all things to just flatly not work like without a word of explanation (or even This file is blocked; do you want to unblock it?) -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Finding a text in raw data(size nearly 10GB) and Printing its memory address using python

2018-04-23 Thread bartc
]==( int )strlen( needle )) { printf( "found at %d\n", offset -( int )strlen( needle )); }} for( int i = l; i; --i )o[ i ]= o[ i - 1 ]; o[ 0 ]= 0; goto next; out: fclose( haystack ); } end: ; } Did you say that you teach programming? -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Can't install Python

2018-04-21 Thread bartc
program or a batch file. The process failed to start (invalid command?). (1 = I do not know what to do ... Thanks in advance Try clicking the Start button and typing python.exe into the search box. (Unless this is Windows 10, then try right-clicking Start and choose Search.) -- bartc

Re: # of Months between two dates

2018-04-06 Thread bartc
weeks? I don't think so.) -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: check if bytes is all nulls

2018-04-01 Thread bartc
that is all zeros but with a sparse smattering of non-zeros? If not very, then just check the bytes one by one. If non-zero, you will know as soon as you see the first non-zero byte, possibly the first one. def allzeros(a): for x in a: if x: return 0 return 1 -- bartc -- https

Re: Python Developer Survey: Python 3 usage overtakes Python 2 usage

2018-03-31 Thread bartc
). But a temporary WiFi link (eg. a free one at McDonald's) can be useful to download extra free apps then they can be used off-line. Of source it might not be very popular without access to social media if that's the main purpose of the device. -- bartc -- https://mail.python.org/mailman/listinfo/python

Re: How to fill in a dictionary with key and value from a string?

2018-03-31 Thread bartc
for c in S: D[c] = c.upper() print (D) Output: {'c': 'C', 'a': 'A', 't': 'T'} But, how to fill in the values? Can I do myDict[0]='A', myDict[1]='B', and so on? Yes, but the result will be {0:'A', 1:'B',...} for which you don't need a dict; a list will do. -- bartc -- https://mail.

Re: Entering a very large number

2018-03-30 Thread bartc
On 27/03/2018 04:49, Richard Damon wrote: On 3/26/18 8:46 AM, bartc wrote: Hence my testing with CPython 3.6, rather than on something like PyPy which can give results that are meaningless. Because, for example, real code doesn't repeatedly execute the same pointless fragment millions

Re: Entering a very large number

2018-03-30 Thread bartc
On 26/03/2018 16:31, Chris Angelico wrote: On Mon, Mar 26, 2018 at 11:46 PM, bartc <b...@freeuk.com> wrote: On 26/03/2018 13:30, Richard Damon wrote: On 3/26/18 6:31 AM, bartc wrote: The purpose was to establish how such int("...") conversions compare in overheads with a

Re: Entering a very large number

2018-03-26 Thread bartc
On 26/03/2018 13:30, Richard Damon wrote: On 3/26/18 6:31 AM, bartc wrote: The purpose was to establish how such int("...") conversions compare in overheads with actual arithmetic with the resulting numbers. Of course if this was done in C with a version that had builtin bi

Re: Entering a very large number

2018-03-26 Thread bartc
On 26/03/2018 03:35, Richard Damon wrote: On 3/25/18 9:37 PM, bartc wrote: So the overhead /can/ be substantial, and /can/ be significant compared with doing bignum calculations. Of course, once initialised, C might be used a hundred times, then the overhead is less significant

Re: Entering a very large number

2018-03-26 Thread bartc
On 26/03/2018 10:34, Steven D'Aprano wrote: On Mon, 26 Mar 2018 02:37:44 +0100, bartc wrote: If I instead initialise C using 'C = int("288712...")', then timings increase as follows: Given that the original number given had 397 digits and has a bit length of 1318, I must adm

Re: Entering a very large number

2018-03-25 Thread bartc
On 26/03/2018 00:27, Richard Damon wrote: On 3/25/18 8:32 AM, bartc wrote: Using CPython on my machine, doing a string to int conversion that specific number took 200 times as long as doing a normal assignment. That conversion took 4 microseconds. Not significant if it's only done once

Re: Entering a very large number

2018-03-25 Thread bartc
On 25/03/2018 16:47, Grant Edwards wrote: On 2018-03-25, bartc <b...@freeuk.com> wrote: On 25/03/2018 02:47, Steven D'Aprano wrote: The Original Poster (OP) is concerned about saving, what, a tenth of a microsecond in total? Hardly seems worth the effort, especially if you're going to

Re: Entering a very large number

2018-03-25 Thread bartc
will also do the conversion when the line is never executed!) Even if you write C = 288714823805077121267142959713039399197760945927972270092651602419743230379915273311632898314463922594197780311092934965557841894944174093380561511397421542416933972905423711002751042080134966731755152859226962916775325475058561019494042000399044321167766199496295392504526987193290703735640322737012784538991261203092448414947289768854060249767681220770716879

Re: Entering a very large number

2018-03-25 Thread bartc
On 25/03/2018 15:01, Christian Gollwitzer wrote: Am 25.03.18 um 14:32 schrieb bartc: Using CPython on my machine, doing a string to int conversion that specific number took 200 times as long as doing a normal assignment. That conversion took 4 microseconds. Not significant if it's only done

Re: Entering a very large number

2018-03-25 Thread bartc
at conversion took 4 microseconds. Not significant if it's only done once. But it might be executed a million times. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Thank you Python community!

2018-03-19 Thread bartc
t the guys who invented C (around 1970) must have been smoking to have come up with some of those ideas. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Enumerating all 3-tuples

2018-03-10 Thread bartc
On 10/03/2018 20:06, Ben Bacarisse wrote: bartc <b...@freeuk.com> writes: [repost as original seems to have gone to email; my newsreader has somehow acquired a 'Reply' button where 'Followup' normally goes.] [I thought it was intended but my reply bounced.] On 10/03/2018 14:2

Re: Enumerating all 3-tuples

2018-03-10 Thread bartc
2 makes a list by pair-wise appending the elements of l1 and l2. What's the output? (And what's the input; how do you invoke pn, if that's how it's done?) -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Enumerating all 3-tuples

2018-03-09 Thread bartc
e Plane number, then plane 1 looks like: 1,1,1 1,2,1 1,3,1 2,1,1 2,2,1 2,3,1 3,1,1 3,2,1 3,3,1 ... ... But whether that has an equivalent traversal path like the diagonals of the 2-D, I don't know. I'm just guessing.) -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Console

2018-03-07 Thread bartc
run dialog that appears then, type cmd and the console window should appear. With Windows 10 all the useful apps that are now hard to find are listed by right-clicking the Start button. The console one is called Command Prompt. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-05 Thread bartc
the code run from a .py file. (I never use interactive mode.) But not when running on a PyPy version of 2.7 (however that is not CPython). -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-04 Thread bartc
en you did want to discard an expensive resource, then X going out of scope, calling del X or whatever, will not work if a copy of X still exists somewhere. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-02 Thread bartc
de resides there. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Functions unnecessarily called in Python/pylifecycle.c:_Py_InitializeCore() ?

2018-03-01 Thread bartc
("__builtins__"); if (builtin_object == NULL) return 0; return 1; } ) -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

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 <b...@freeuk.com> 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 4

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

2018-02-26 Thread bartc
per second, so it's not bad going. Of course, the C version will generate them at over 100 million per second. -- bartc -- https://mail.python.org/mailman/listinfo/python-list

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

2018-02-26 Thread bartc
On 26/02/2018 20:27, bartc wrote: On 26/02/2018 19:50, Chris Angelico wrote: On Tue, Feb 27, 2018 at 6:37 AM, Rick Johnson So what? Latency is latency. And whether it occurs over the course of one heavily recursive algorithm that constitutes the depth and breadth of an entire program (a la

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

2018-02-26 Thread bartc
same speed with i64(), without it, or with both i64() and i64a().) -- bartc -- https://mail.python.org/mailman/listinfo/python-list

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

2018-02-26 Thread bartc
On 26/02/2018 17:05, Ben Bacarisse wrote: bartc <b...@freeuk.com> writes: A C version is given below. (One I may have messed around with, which I'm not sure works properly. For an original, google for Marsaglia and KISS64 or SUPRKISS64.) The version I know uses unsigned integers. D

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

2018-02-26 Thread bartc
On 26/02/2018 15:09, Chris Angelico wrote: On Tue, Feb 27, 2018 at 2:02 AM, bartc <b...@freeuk.com> 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 yo

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

2018-02-26 Thread bartc
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 be 5255210926702073855. OK, I'll try that. I have that Python

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

2018-02-26 Thread bartc
program, but optimises hot paths in the special Python interpreter. One written in [R]Python. Or something... -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

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

2018-02-26 Thread bartc
On 26/02/2018 13:42, Ned Batchelder wrote: On 2/26/18 7:13 AM, bartc wrote: A C version is given below. (One I may have messed around with, which I'm not sure works properly. For an original, google for Marsaglia and KISS64 or SUPRKISS64.) Most integers are unsigned, which have well

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

2018-02-26 Thread bartc
on acceleration projects and tracing JIT compilers. To those people however, such a benchmark can be a useful yardstick of progress.) -- bartc -- https://mail.python.org/mailman/listinfo/python-list

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

2018-02-26 Thread bartc
On 26/02/2018 11:40, Chris Angelico wrote: On Mon, Feb 26, 2018 at 10:13 PM, bartc <b...@freeuk.com> 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

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

2018-02-26 Thread bartc
3) x = s+xcng+xs print ("Does x= 4013566000157423768") print (" x=",x) start() -- (The code performs N iterations of a random number generator. You get the result expected, ie. x=401...768, when N is a billion.) -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

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

2018-02-24 Thread bartc
On 24/02/2018 02:05, Steven D'Aprano wrote: On Fri, 23 Feb 2018 19:25:35 +, bartc wrote: Python is 10 times slower than a competitor = doesn't matter My language is 1.5 times slower than the big boys' = matters a great deal As for Python's order-of-magnitude speed difference, thank you

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

2018-02-24 Thread bartc
, it won't. Benchmarks need to be honest. But Fibonacci I think can't use that optimisation (although gcc seems to have found another way of not that much work). -- bartc -- https://mail.python.org/mailman/listinfo/python-list

  1   2   3   4   5   6   7   8   9   10   >