Re: Question about math.pi is mutable

2015-11-08 Thread BartC
On 08/11/2015 11:30, Steven D'Aprano wrote: On Sun, 8 Nov 2015 09:40 pm, Bartc wrote: This is what I mean about people not understanding it! I'm pretty sure I understand what *I* mean by constant, and what Pascal means by it, and why the Pascal meaning doesn't quite match wha

Re: Question about math.pi is mutable

2015-11-08 Thread BartC
On 08/11/2015 11:50, Marko Rauhamaa wrote: BartC : On 08/11/2015 11:02, Marko Rauhamaa wrote: That elegant dynamism comes at a cost: method lookup is not a constant memory offset. Rather, it is a dictionary lookup. I've never understood why this seems to be necessary in Python. Why do

Re: Question about math.pi is mutable

2015-11-08 Thread BartC
On 08/11/2015 12:43, Marko Rauhamaa wrote: BartC : On 08/11/2015 11:50, Marko Rauhamaa wrote: import shutil class Source: def __init__(self): self.remaining = "hello world" def read(s

Re: Question about math.pi is mutable

2015-11-08 Thread BartC
On 08/11/2015 15:59, Michael Torrie wrote: On 11/08/2015 04:19 AM, BartC wrote: That elegant dynamism comes at a cost: method lookup is not a constant memory offset. Rather, it is a dictionary lookup. I've never understood why this seems to be necessary in Python. Why do names have

Re: Question about math.pi is mutable

2015-11-08 Thread BartC
On 08/11/2015 18:01, Chris Angelico wrote: On Mon, Nov 9, 2015 at 4:54 AM, BartC wrote: That would be true for locals as well. But as far as I can tell from the CPython source code, byte-codes uses an index to represent a local, which represents an entry into a linear table. I can't quit

Re: Question about math.pi is mutable

2015-11-08 Thread BartC
On 08/11/2015 21:00, Ben Finney wrote: BartC writes: I've never understood why this seems to be necessary in Python. Why do names have to be looked up? (I'm assuming this is searching by name in some sort of table.) No, it is literally looking the name up as a key in a namespace

Re: Question about math.pi is mutable

2015-11-08 Thread BartC
On 08/11/2015 23:13, Dennis Lee Bieber wrote: On Sun, 8 Nov 2015 18:58:36 +, BartC declaimed the following: But then, you say that additional attributes, potentially millions of different ones, can be invented at runtime. Although I don't see how it can remove names that are part o

Re: Question about math.pi is mutable

2015-11-08 Thread BartC
On 09/11/2015 00:00, Ben Finney wrote: BartC writes: Is this typical Python code? Creating global objects in other modules (or writing all over essential data structures in a library module). Not “creating global objects”, but changing the referent of a name in some other module. Yes

Re: Question about math.pi is mutable

2015-11-09 Thread BartC
On 09/11/2015 02:23, Steven D'Aprano wrote: On Mon, 9 Nov 2015 09:35 am, BartC wrote: import m a=10 b=20 c=30 m.f() The set of global names the compiler knows will be ("m","a","b","c"). Wrong. Up to the line "c=30", the set of names

Re: Question about math.pi is mutable

2015-11-09 Thread BartC
On 09/11/2015 01:04, Ben Finney wrote: Chris Angelico writes: Hmm, then I was misunderstanding what BartC was advocating. I didn't think it would *fail* in the presence of dynamic attributes, but merely *perform suboptimally* (and presumably worse than current CPython). There isn&#x

Re: Question about math.pi is mutable

2015-11-10 Thread BartC
ess interested with speeding up CPython, for one thing because it is not going to speed things up by ten times, so there seems little point. -- BartC -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about math.pi is mutable

2015-11-12 Thread BartC
On 12/11/2015 20:40, Thomas 'PointedEars' Lahn wrote: Chris Angelico wrote: […] Ben Finney […] wrote: I recommend you ignore that request; “Bartc” is fine as a name here, IMO. Given that LARTC means Linux Advanced Routing and Traffic Control, I'm guessing Bartc is all about

Re: A Program that prints the numbers from 1 to 100

2015-11-14 Thread BartC
quot;) print (58) print (59) print ("FizzBuzz") print (61) print (62) print ("Fizz") print (64) print ("Buzz") print ("Fizz") print (67) print (68) print ("Fizz") print ("Buzz") print (71) print ("Fizz") print (73) print (74) print (&quo

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

2015-11-18 Thread BartC
ough to me to check for a missing parameter, and to assign whatever default value was designated ([] in this case). (How does the default mechanism work now?) -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

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

2015-11-18 Thread BartC
On 18/11/2015 23:22, Chris Angelico wrote: On Thu, Nov 19, 2015 at 10:14 AM, BartC wrote: On 18/11/2015 22:11, Ian Kelly wrote: On Wed, Nov 18, 2015 at 2:08 PM, fl wrote: Hi, I have tried the below function and find that it can remember the previous setting value to 'val'. I

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

2015-11-19 Thread BartC
On 19/11/2015 01:59, Chris Angelico wrote: On Thu, Nov 19, 2015 at 12:41 PM, BartC wrote: On 18/11/2015 23:22, Chris Angelico wrote: On the contrary, it is certain always to be that exact object. But, not the same value that appears as the default? Nope. Mutable objects are never

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

2015-11-19 Thread BartC
On 19/11/2015 12:19, Steven D'Aprano wrote: On Thu, 19 Nov 2015 10:14 am, BartC wrote: Consider this pair of functions: def expensive(): # Simulate some expensive calculation or procedure. time.sleep(100) return random.randint(1, 6) def demo(arg=expensive()): r

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

2015-11-19 Thread BartC
On 19/11/2015 16:01, Steven D'Aprano wrote: On Fri, 20 Nov 2015 12:19 am, BartC wrote: You know, for somebody who claims to design and implement your own languages, you sometimes go to a remarkable effort to claim to be a dummy. You write your own interpreter, but can't unders

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

2015-11-19 Thread BartC
On 19/11/2015 17:45, Chris Angelico wrote: On Fri, Nov 20, 2015 at 4:30 AM, BartC wrote: The whole concept of 'mutable' default is alien to me. A default is just a convenient device to avoid having to write: fn(0) or fn("") or fn([]) You just write fn() instead. But

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

2015-11-19 Thread BartC
On 19/11/2015 18:26, Mark Lawrence wrote: On 19/11/2015 18:19, BartC wrote: if you write A=B then something of B needs to have been copied into A, even if it's just the reference that B contains. Otherwise it would be difficult to get A to refer to the same object as B. Please, PLEAS

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

2015-11-19 Thread BartC
On 19/11/2015 19:09, Chris Angelico wrote: On Fri, Nov 20, 2015 at 5:50 AM, BartC wrote: But you're not going to tell me what it is I got wrong! I said that Python's "=" does a very shallow copy. And I stated that in A=B, something of B must be copied into A. I (and pr

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

2015-11-19 Thread BartC
On 19/11/2015 19:19, Chris Angelico wrote: On Fri, Nov 20, 2015 at 5:19 AM, BartC wrote: But every choice has consequences. Steven gave you a few examples of the consequences of late-binding default arguments. For example, can you translate this into (one of) your language(s), and explain

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

2015-11-19 Thread BartC
On 19/11/2015 22:55, Michael Torrie wrote: On 11/19/2015 02:21 PM, BartC wrote: (Python returns 42; so that means my languages are more dynamic than Python? That's hard to believe!) It tells me your language does late binding for default arguments, which does mean the default argumen

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

2015-11-20 Thread BartC
On 20/11/2015 01:05, Steven D'Aprano wrote: On Fri, 20 Nov 2015 04:30 am, BartC wrote: On 19/11/2015 16:01, Steven D'Aprano wrote: [...] The whole concept of 'mutable' default is alien to me. A default is just a convenient device to avoid having to write: f

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

2015-11-20 Thread BartC
On 20/11/2015 12:12, Ned Batchelder wrote: On Friday, November 20, 2015 at 6:59:54 AM UTC-5, BartC wrote: On 20/11/2015 01:05, Steven D'Aprano wrote: On Fri, 20 Nov 2015 04:30 am, BartC wrote: On 19/11/2015 16:01, Steven D'Aprano wrote: [...] The whole concept of 'muta

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

2015-11-20 Thread BartC
On 20/11/2015 12:28, Marko Rauhamaa wrote: BartC : We're arguing at cross-purposes then since you are obviously interested in these esoteric aspects, The Ackermann function really is an esoteric example, but the other example that has been discussed here can make practical use o

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

2015-11-20 Thread BartC
. Which may irritate him to get 2 copies instead of one, but so it goes. I am talking about BartC as well, but since this is his thread, I assume he is here.) Actually that thread was started by 'fl'. Sometimes you want to understand what you are doing. Sometimes you just want to d

Re: *= operator

2015-11-21 Thread BartC
doing in-place modification for example), but that shouldn't matter when bill is just a number. -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Problem to read from array

2015-11-21 Thread BartC
7;b3\n', 'c3\n'] Probably you'd want to get rid of those \n characters. (I don't know how off-hand as I'm not often write in Python.) The last bit could also be written: for param in params: print (params) but I needed the row index. -- BartC -- https://mail.python.org/mailman/listinfo/python-list

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

2015-11-22 Thread BartC
On 22/11/2015 03:43, Steven D'Aprano wrote: On Fri, 20 Nov 2015 10:59 pm, BartC wrote: On 20/11/2015 01:05, Steven D'Aprano wrote: Here's another use for function defaults, as static storage: [...] This is a quick and easy way to memoise a function which would otherwise b

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

2015-11-22 Thread BartC
On 22/11/2015 13:21, BartC wrote: On 22/11/2015 03:43, Steven D'Aprano wrote: Quite frankly, to call it such demonstrates a considerable level of ignorance about basic programming idioms. Not just Python, but general purpose programming. I've come to learn that basic idioms are

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

2015-11-22 Thread BartC
On 23/11/2015 00:04, Mark Lawrence wrote: On 22/11/2015 23:44, Steven D'Aprano wrote: On Mon, 23 Nov 2015 12:21 am, BartC wrote: But if it's used for static storage, then why not just use static storage? That's a simpler and more general concept than memoisation. /head-des

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

2015-11-23 Thread BartC
On 23/11/2015 07:47, Steven D'Aprano wrote: I think it would be cleaner and better if Python had dedicated syntax for declaring static local variables: Interesting. So why is it that when /I/ said: > On Mon, 23 Nov 2015 12:21 am, BartC wrote: > >> But if it's used fo

Re: Finding scores from a list

2015-11-24 Thread BartC
rt counting at 0). To find the entry for particular name, you have to search for it (for a list entry where the dict key "name" gives you the value you expect, ie. "gengyang" in this example). So a dict of dicts was a better idea. -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

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

2015-11-24 Thread BartC
ll exists! (And ideally the file is first closed via one of the handles.) From your example, the syntax '[]' is roughly equivalent to 'create_empty_file()' in my analogy. (I don't really want to get back to default arguments, but that would extend to: de

Re: Raspberry pi, python and robotics

2014-09-05 Thread BartC
mal non-storage oscilloscope wasn't directly useful for the complex non-repeating signals you get with computer boards. -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Re: Opportunity missed by Python ?

2011-10-13 Thread BartC
le, and they re-invent C! https://code.google.com/p/dart/source/browse/branches/bleeding_edge/dart/client/samples/spirodraw/Spirodraw.dart -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Lists and arrays

2013-04-22 Thread BartC
st: [a,1,2] When I do it like this: list=array[0]+ array[3]+ array[4] I get an error: "TypeError: unsupported operand type(s) for +: 'numpy.ndarray' and 'numpy.ndarray'" You're calculating a+1+2. Probably a isn't something that can be added to 1+2. -- B

Re: Wrapping paper, anyone ?

2009-12-16 Thread bartc
"simon" wrote in message news:a50b1c21-287b-498d-a8c3-51a3a2f94...@k9g2000vbl.googlegroups.com... #!/usr/bin/env python from math import * from random import * import cairo from cairo import Context What's cairo? -- http://mail.python.org/mailman/listinfo/python-list

Re: Scripting (was Re: Python books, literature etc)

2010-01-09 Thread bartc
tions and operations). If it runs a lot slower than those other languages, then you're probably doing some programming. And with programs where the runtime is not significant, it could be either... -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: chr(12) Form Feed in Notepad

2010-01-16 Thread bartc
1970's are over, and neither Notepad nor your printer attempts to maintain compatibility with a Teletype model 37. Odd that TXT files under Windows still use the same 13 (carriage return), 10 (linefeed) and 9 (tab) codes that used to work on my ASR 33. So why not code 12 (formfee

Re: chr(12) Form Feed in Notepad

2010-01-16 Thread bartc
"Steve Holden" wrote in message news:mailman.1007.1263682208.28905.python-l...@python.org... bartc wrote: "Nobody" wrote in message news:pan.2010.01.16.04.24.18.437...@nowhere.com... On Fri, 15 Jan 2010 10:42:43 -0800, W. eWatson wrote: I thought I'd put a page

Re: chr(12) Form Feed in Notepad

2010-01-17 Thread bartc
"Dennis Lee Bieber" wrote in message news:mailman.1021.1263702437.28905.python-l...@python.org... On Sat, 16 Jan 2010 23:59:52 GMT, "bartc" declaimed the following in gmane.comp.python.general: My point was these other control codes from over 30 years ago are still i

Re: basic Class in Python

2010-01-18 Thread bartc
and right Any particular reason why two, and not one (or three)? In some fonts it's difficult to tell how many as they run together. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: The rap against "while True:" loops

2009-10-11 Thread bartc
o be seen by the brigade who hate all break, exit, goto and multiple return statements, then I won't bother. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-29 Thread bartc
live or in a file, or some combination); whether to call the file .py or .pyw; the difference between console and graphical programs and so on. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-30 Thread bartc
"Alf P. Steinbach" wrote in message news:hcdlsp$9a...@news.eternal-september.org... * bartc: "Alf P. Steinbach" wrote in message news:hc8pn3$dd...@news.eternal-september.org... [Cross-posted comp.programming and comp.lang.python] You use the highly commercial-l

Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-17 Thread bartc
in some god-forsaken syntax like C++... ...For some reason I can't quite understand, this sort of clear syntax seems to be looked down on by 'real' programmers, who perhaps think code like this can't be taken seriously. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Language mavens: Is there a programming with "if then else ENDIF"syntax?

2009-11-18 Thread bartc
esn't have endif. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and Ruby

2010-02-02 Thread bartc
f is not obvious. I'd say that having this "&" symbol in front of "foo" makes it more obvious than just foo by itself. But I agree not quite as clean. Another thing is that you have to know whether "bar" is a function, or a function ref, and use the appropriate syntax. Sometimes this is helpful, sometimes not. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and Ruby

2010-02-02 Thread bartc
Jonathan Gardner wrote: On Feb 2, 7:23 am, "bartc" wrote: Jonathan Gardner wrote: One of the bad things with languages like perl and Ruby that call without parentheses is that getting a function ref is not obvious. You need even more syntax to do so. In perl: foo(); # Call &#x

Re: Your beloved python features

2010-02-05 Thread bartc
it. That might be true when used to code actual algorithms using basic features. But a lot of Pythonisms would appear mysterious to someone who doesn't know the language (for example, what does :: mean in an array index). Or perhaps pseudo-code is much more advanced these day

Re: Dreaming of new generation IDE

2010-02-05 Thread bartc
if b==0 and i==0 and u==0: drawtext(s) elif b==1 and i==0 and u==0: drawtextb(s) and so on. With half-a-dozen or more booleans, this becomes completely impractical. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Dreaming of new generation IDE

2010-02-06 Thread bartc
"Arnaud Delobelle" wrote in message news:m28wb6ypfs@googlemail.com... "Gabriel Genellina" writes: En Fri, 05 Feb 2010 19:22:39 -0300, bartc escribió: "Steve Holden" wrote in message news:mailman.1998.1265399766.28905.python-l...@python.org... Arnaud

Re: lists of variables

2010-02-21 Thread bartc
So I figure my initial example doesn't work because if you assign a That shows a different outlook. I would have said your first example works as expected and it was the second example that was strange, possibly due to shallow instead of deep copies by Python. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Named loops for breaking

2010-03-11 Thread bartc
are used infrequently in final code. But they are handy when developing code too: you don't want to waste time refactoring, and generally turning code upside-down, when the code has to be rewritten a dozen times anyway. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Need advice on starting a Python group

2010-03-12 Thread bartc
a hard time finding volunteers. And even when we've had volunteers, hardly anyone shows up! Any suggestions would be appreciated. Try and get a girl or two interested in coming to the meetings... -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Unladen Swallow dead?

2010-11-18 Thread BartC
e performance improvement achieved was so low that cluttering up CPython with a JIT system and LLVM probably is a lose. LLVM. Ok, that explains a lot. (LLVM is a huge, complex system). -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparisons of incompatible types

2010-12-07 Thread BartC
ring the string representations of each element. So some sorts will make sense, and others (such as "<" or ">") won't. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: while True or while 1

2010-12-16 Thread BartC
ing of 27.3 ns per iteration. So "a bit" is hardly worth considering for most programs, is it? One these is 30% faster than the other. That's an appreciable difference, which you can't really just dismiss. And you can't tell what the overall effect on a program wil

Re: while True or while 1

2010-12-16 Thread BartC
"Steve Holden" wrote in message news:mailman.54.1292502247.6505.python-l...@python.org... On 12/16/2010 5:44 AM, BartC wrote: One these is 30% faster than the other. That's an appreciable difference, which you can't really just dismiss. shol...@lifeboy ~ $ python

Re: Trying to parse a HUGE(1gb) xml file

2010-12-25 Thread BartC
o, just a simple diagram showing how to plug it into the phone socket!). -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Trying to parse a HUGE(1gb) xml file

2010-12-28 Thread BartC
hing like this)? And why not use 1 and 0 for TRUE and FALSE? Even the consumer appliances in my house have 1 and 0 on their power switches! With the advantage that they are internationally recognised. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Trying to decide between PHP and Python

2011-01-06 Thread BartC
t. One with zero instructions might be even simpler than that: http://en.wikipedia.org/wiki/Zero_instruction_set_computer -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Problems of Symbol Congestion in Computer Languages

2011-02-20 Thread BartC
hought that syllable was stressed anyway.) -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Normalizing A Vector

2010-08-02 Thread Bartc
en vectors are known to have 3 elements: def norm3d(v): L = math.sqrt((v[0]*v[0]+v[1]*v[1]+v[2]*v[2])) return (v[0]/L,v[1]/L,v[2]/L) (Strangely, changing those divides to multiplies made it slower.) -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Normalizing A Vector

2010-08-02 Thread Bartc
"Alain Ketterlin" wrote in message news:87fwyxgvuv@dpt-info.u-strasbg.fr... > "Bartc" writes: >> def norm3d(v): >> L = math.sqrt((v[0]*v[0]+v[1]*v[1]+v[2]*v[2])) >> return (v[0]/L,v[1]/L,v[2]/L) >> >> (Strangely, changing those d

Re: Python "why" questions

2010-08-09 Thread Bartc
a newborn baby is zero years > old or would it be more natural to call them a one year old? Zero > based counting is perfectly natural. Depends whether you are counting (discrete) things, or measuring them (over a continuous range). You would start counting at 1, but start measuring fro

Re: Python "why" questions

2010-08-09 Thread Bartc
ir own array > manipulation. Lots of things require this sort of calculation, eg. how many pages are needed to print 267 lines of text at 60 lines per page? These counts are 1-based so it's (L-1)/P+1 (integer divide), or 5 pages. If we switch to 0-based counting, it's just L/P ('266' lines require '4' pages), but who's going to explain that to the user? -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: 79 chars or more?

2010-08-17 Thread BartC
ght be wrong). I generally use 100 columns. It's useful for being able to write same-line comments with meaningful content... (I've used 80-column hardware (teletypes and such) years ago, I thought such restrictions had vanished long ago) -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: 79 chars or more?

2010-08-18 Thread BartC
7;t remember the ASR-33 :-) ASR33s I think might have been 72 columns wide (and punched cards had a similar restriction). However, lineprinter output was more likely to be 132 columns. -- bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: 79 chars or more?

2010-08-18 Thread BartC
"Roy Smith" wrote in message news:roy-181632.07571818082...@news.panix.com... In article , "BartC" wrote: >> Remember, the old hardcopy terminals used to produce >> 132-character-wide >> listings. > > Those of you who think "old hardcopy t

Re: Iterative vs. Recursive coding

2010-08-25 Thread BartC
the code compiled? *wink* You underestimate how much programming (of applications) can be done without needing any of this stuff. Needless to say, I didn't last long !-) And rightly so :) I guess they wanted code that could be maintained by anybody. -- Bartc --- news://freenews

Re: len() should always return something

2009-07-24 Thread bartc
ould it print 3 (the elements in [10,20,30]), or 1 (treating [10,20,30] as a potential list containing the single element [10,20,30])? -- bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread bartc
ave helped the speed any. Nor the memory consumption. A for-loop, for iterating over a simple sequence, should be one of the fastest things in the language. [Presumably the internal code that created those consecutive integers used a more conventional looping method...] -- Bartc -- ht

Re: Numeric literals in other than base 10 - was Annoying octal notation

2009-08-23 Thread bartc
wrote in message news:h6r4fb$18...@aioe.org... In comp.lang.python James Harris wrote: On 22 Aug, 10:27, David <71da...@libero.it> wrote: ... What about 2_1011, 8_7621, 16_c26h or 2;1011, 8;7621, 16;c26h ? They look good - which is important. The trouble (for me) is that I want the not

Re: Numeric literals in other than base 10 - was Annoying octal notation

2009-08-23 Thread bartc
ly too confusing, No issue of what base the base indicator is expressed in. It can be assumed however that .9. isn't in binary? That's a neat idea. But an even simpler scheme might be: .octal.100 .decimal.100 .hex.100 .binary.100 .trinary.100 until it gets to this anyway: .thiryse

Re: Speed-up for loops

2010-09-03 Thread BartC
terated between the values of the list! So Python had the distinction of being one of the slowest languages in which to do nothing (ie. running an empty loop). -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Speed-up for loops

2010-09-05 Thread BartC
t relying on accelerators, and not have to wait two and a half minutes (or whatever) for a simple test to complete. -- bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: Speed-up for loops

2010-09-05 Thread BartC
"Steven D'Aprano" wrote in message news:4c83b425$0$28657$c3e8...@news.astraweb.com... On Sun, 05 Sep 2010 12:28:47 +0100, BartC wrote: It would be nice if you could directly code low-level algorithms in it without relying on accelerators, and not have to wait two and a h

Re: Speed-up for loops

2010-09-06 Thread BartC
"Stefan Behnel" wrote in message news:mailman.470.1283712666.29448.python-l...@python.org... BartC, 05.09.2010 19:09: All those compilers that offer loop unrolling are therefore wasting their time... Sometimes they do, yes. Modifying the OP's code a little: a = 0

Re: Speed-up for loops

2010-09-06 Thread BartC
"Stefan Behnel" wrote in message news:mailman.485.1283772019.29448.python-l...@python.org... BartC, 06.09.2010 12:38: (2) Integer arithmetic seems to go straight from 32-bits to long integers; why not use 64-bits before needing long integers? You are making assumptions based on P

Re: Speed-up for loops

2010-09-07 Thread BartC
"Steven D'Aprano" wrote in message news:4c85adfe$0$5$c3e8...@news.astraweb.com... On Mon, 06 Sep 2010 11:38:22 +0100, BartC wrote: Manually unrolling such a loop four times (ie. 4 copies of the body, and counting only to 25 million) increased the speed by between

Re: Speed-up for loops

2010-09-07 Thread BartC
"David Cournapeau" wrote in message news:mailman.546.1283897932.29448.python-l...@python.org... On Sun, Sep 5, 2010 at 8:28 PM, BartC wrote: One order of magnitude (say 10-20x slower) wouldn't be so bad. That's what you might expect for a dynamically typed, interprete

Re: Speed-up for loops

2010-09-08 Thread BartC
"Steven D'Aprano" wrote in message news:4c878be5$0$3$c3e8...@news.astraweb.com... On Tue, 07 Sep 2010 11:00:03 +0100, BartC wrote: for i in xrange(1): a = a + f(i) With Python 3 and def f(x): return x+1, unrolling this loop 4x improved speed by 15%; 4.00 min

Re: Speed-up for loops

2010-09-09 Thread BartC
"Stefan Behnel" wrote in message news:mailman.563.1283921317.29448.python-l...@python.org... BartC, 08.09.2010 03:45: Getting back to the OP's code again (trivial and pointless as it might seem), I got these results: C (gcc 3.4.5 -O3) 0.8 secs C (DMC-o) 2.3 secs C (lccwin

Re: sequence multiplied by -1

2010-09-26 Thread BartC
meaningful symantics. Simply put, a sequence multiplied by -1 can give a reversed sequence. Then for any sequence "seq", and integer n>0, we can have "seq * -n" producing "(seq * -1) * n". Any thoughts? Gimmicky. Best to define multiplication only by unsign

Re: "Strong typing vs. strong testing"

2010-09-28 Thread BartC
the standard units are radians, and mm. Every other calculation uses implied units. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: "Strong typing vs. strong testing"

2010-10-01 Thread BartC
nd a language that has no compiler generating faster code than C... But those implementers have to try very hard to beat C. Meanwhile C can be plenty fast without doing anything special. When Intel will realize that 99% of its users are running VM Which one? -- Bartc -- http://mail.python.or

Re: discussion

2010-10-01 Thread BartC
firstdigit=n//(10**(digits-1)) if firstdigit!=lastdigit: return False if digits==2: return True middledigits=n//10-firstdigit*(10**(digits-2)) return fpalindrome(middledigits) print fpalindrome(12345678987654321) -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: "Strong typing vs. strong testing"

2010-10-01 Thread BartC
"Pascal J. Bourguignon" wrote in message news:87zkuyjawh@kuiper.lan.informatimago.com... "BartC" writes: "Pascal J. Bourguignon" wrote in message When Intel will realize that 99% of its users are running VM Which one? Any implementation of a contr

Re: "Strong typing vs. strong testing"

2010-10-01 Thread BartC
ared with 3.5 seconds, for my own interpreted, dynamic language, and 0.6 seconds for C.) -- bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: "Strong typing vs. strong testing"

2010-10-01 Thread BartC
"Pascal J. Bourguignon" wrote in message news:877hi1iq2o@kuiper.lan.informatimago.com... "BartC" writes: (defun fib (n) (if (< n 2) n (+ n (fib (- n 1)) (fib (- n 2)) ) )) But it gave the wrong results and it took ages to figure out why. Even I

Re: if the else short form

2010-10-06 Thread BartC
abel the cases for legibility. You can do, until you want to insert an item in the middle and have to re-label everything... For more complex cases I'd just use a conventional case or switch expression which (in my syntax at least), also evaluates just one expression, and returns that value. But then you can also start using if-else chains, so this is no longer a compact construction useful in an expression. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: if the else short form

2010-10-06 Thread BartC
"Lawrence D'Oliveiro" wrote in message news:i8j0dg$lh...@lust.ihug.co.nz... In message , BartC wrote: x = ("One","Two","Three") [i-1] While this works for i = 1,2,3, it goes funny for i=0,-1,-2, and generates an error for the rest ...

Re: if the else short form

2010-10-07 Thread BartC
On Thu, 07 Oct 2010 01:36:33 +0100, BartC wrote: However, as I mentioned, one problem here is having to evaluate all the items in the list before selecting one: ... x = {1 : fna(), 2 : fnb(), 3 : fnc()}.get(i, "None Of The Above") "Mel" wrote in me

Re: Many newbie questions regarding python

2010-10-08 Thread BartC
assigned. 2 - If I declare a class with some member variables, is is strictly necessary This is where I bail out... -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: if the else short form

2010-10-08 Thread BartC
ef test showed an list+if (or is it tuple? I can never remember) construction was much faster and much cleaner: x = ("One","Two","Three")[i-1] if 1<=i<=3 else "Other" "NevilleDNZ" wrote: "BartC" wrote: Probably there are

Re: "Strong typing vs. strong testing"

2010-10-12 Thread BartC
do all that if angles are just numbers. The definition of a radian is length/length (or m/m) which simplifies to dimensionless. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list

Re: "Strong typing vs. strong testing"

2010-10-12 Thread BartC
"RG" wrote in message news:rnospamon-20651e.17410012102...@news.albasani.net... In article , "BartC" wrote: "Thomas A. Russ" wrote in message > But radians are dimensionless. But they are still units No, they aren't. so that you can choose to us

<    5   6   7   8   9   10   11   12   >