On Mar 5, 9:44 pm, John Nagle wrote:
> All functions in Python can be replaced dynamically. While they're
> running. From another thread. Really.
Indeed, and I find this feature VERY useful when coding. Two places
I've used it are:
1) in GUI coding (say, when I have a panel of buttons, an
"BartC" wrote:
> Another example:
>
> pi=3.141592654
>
> print ("pi is:",pi)
>
> pi=42
>
> print ("pi is now:",pi)
>
> which is clearly undesirable.
Maybe not if you're the state of Indiana :)
--
http://mail.python.org/mailman/listinfo/python-list
"Steven D'Aprano" wrote in message
news:4d743f70$0$29984$c3e8da3$54964...@news.astraweb.com...
On Sun, 06 Mar 2011 12:59:55 -0800, Westley Martínez wrote:
I'm confused. Can someone tell me if we're talking about constant as in
'fixed in memory' or as in 'you can't reassign' or both?
Python
Steven D'Aprano writes:
>> L[0].append(5) # mutate L, in some reasonable sense of "mutate"
>
> You haven't mutated the tuple called "L". You've mutated its internal
> components, which are lists. If you wanted them to also be immutable, you
> should have used tuples :)
Obviously you are
On Mon, 07 Mar 2011 13:20:39 -0800, Paul Rubin wrote:
> Steven D'Aprano writes:
>> but I call that a feature, not a bug. If you want an immutable
>> constant, use a tuple, not a list.
>
> Nope:
>
> L = ([1,2],[3,4]) # tuple
> L[0].append(5) # mutate L, in some reasonable sense of "
Now you're just muddying the terminology!
~/santa
On Mon, Mar 7, 2011 at 1:20 PM, Paul Rubin wrote:
> Steven D'Aprano writes:
> > but I call that a feature, not a bug. If you want an immutable constant,
> > use a tuple, not a list.
>
> Nope:
>
>L = ([1,2],[3,4]) # tuple
>L[0].append(
Steven D'Aprano writes:
> but I call that a feature, not a bug. If you want an immutable constant,
> use a tuple, not a list.
Nope:
L = ([1,2],[3,4]) # tuple
L[0].append(5) # mutate L, in some reasonable sense of "mutate"
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 06 Mar 2011 12:59:55 -0800, Westley Martínez wrote:
> I'm confused. Can someone tell me if we're talking about constant as in
> 'fixed in memory' or as in 'you can't reassign' or both?
Python already has fixed in memory constants. They are immutable objects
like strings, ints, floats, et
John Nagle wrote:
"let" allows the usual optimizations - constant folding, hoisting
out of loops, compile time arithmetic, unboxing, etc.
Only if the compiler knows the value of the constant,
which it won't if it's defined in a different module.
--
Greg
--
http://mail.python.org/mailman/listi
On Sun, 2011-03-06 at 07:58 +, Steven D'Aprano wrote:
> On Sat, 05 Mar 2011 20:33:49 -0800, Westley Martínez wrote:
>
> > On Sat, 2011-03-05 at 18:37 -0800, John Nagle wrote:
> >> It's worth having some syntax for constants. I'd suggest
> >> using "let":
>
> +1 on syntax for constants. -
On Sat, 05 Mar 2011 20:33:49 -0800, Westley Martínez wrote:
> On Sat, 2011-03-05 at 18:37 -0800, John Nagle wrote:
>> It's worth having some syntax for constants. I'd suggest
>> using "let":
+1 on syntax for constants. -0 for "let". I'd prefer something more
explicit, like "const".
> I'm a
On Thu, 03 Mar 2011 06:19:41 -0800, Westley Martínez wrote:
> On Wed, 2011-03-02 at 19:45 -0800, Yingjie Lan wrote:
>> Hi everyone,
>>
>> Variables in Python are resolved dynamically at runtime, which comes at
>> a performance cost. However, a lot of times we don't need that feature.
>> Variables
On Thu, 03 Mar 2011 08:52:16 -0800, Rafe Kettler wrote:
>> Finally, Python 3 introduced type annotations, which are currently a
>> feature looking for a reason.
>
> By type annotations, do you mean function annotations (see PEP 3107,
> http://www.python.org/dev/peps/pep-3107/)? Or is this some ot
On Mar 5, 7:46 pm, Corey Richardson wrote:
> On 03/05/2011 10:23 PM, MRAB wrote:
>
> > Having a fixed binding could be useful elsewhere, for example, with
> > function definitions:
> > [..]
> > fixed PI = 3.1415926535897932384626433832795028841971693993751
>
> > fixed def squared(x):
> >
Shouldn't this go to python-ideas?
Anyway, I'm partial to "static".
~/santa
On Sat, Mar 5, 2011 at 8:33 PM, Westley Martínez wrote:
> On Sat, 2011-03-05 at 18:37 -0800, John Nagle wrote:
> > On 3/2/2011 9:27 PM, Steven D'Aprano wrote:
> > > On Wed, 02 Mar 2011 19:45:16 -0800, Yingjie Lan wrot
On 3/5/2011 7:46 PM, Corey Richardson wrote:
On 03/05/2011 10:23 PM, MRAB wrote:
Having a fixed binding could be useful elsewhere, for example, with
function definitions:
[..]
fixed PI = 3.1415926535897932384626433832795028841971693993751
fixed def squared(x):
return x * x
On Sat, 2011-03-05 at 18:37 -0800, John Nagle wrote:
> On 3/2/2011 9:27 PM, Steven D'Aprano wrote:
> > On Wed, 02 Mar 2011 19:45:16 -0800, Yingjie Lan wrote:
> >
> >> Hi everyone,
> >>
> >> Variables in Python are resolved dynamically at runtime, which comes at
> >> a performance cost. However, a l
A function object can get bound to a name, too:
def foo(x):
return x + 1
foo = lambda x: x - 1
assert foo(1) == 0
~/santa
On Sat, Mar 5, 2011 at 7:46 PM, Corey Richardson wrote:
> On 03/05/2011 10:23 PM, MRAB wrote:
> > Having a fixed binding could be useful elsewhere, for example, with
On 03/05/2011 10:23 PM, MRAB wrote:
> Having a fixed binding could be useful elsewhere, for example, with
> function definitions:
> [..]
> fixed PI = 3.1415926535897932384626433832795028841971693993751
>
> fixed def squared(x):
> return x * x
This question spawns from my ignora
On 06/03/2011 02:37, John Nagle wrote:
On 3/2/2011 9:27 PM, Steven D'Aprano wrote:
On Wed, 02 Mar 2011 19:45:16 -0800, Yingjie Lan wrote:
Hi everyone,
Variables in Python are resolved dynamically at runtime, which comes at
a performance cost. However, a lot of times we don't need that feature
> It's worth having some syntax for constants. I'd suggest
>using "let":
>let PI = 3.1415926535897932384626433832795028841971693993751
in to many languages, let is just a setter. why not just const pye = 3.14...
--
http://mail.python.org/mailman/listinfo/python-list
On 3/2/2011 9:27 PM, Steven D'Aprano wrote:
On Wed, 02 Mar 2011 19:45:16 -0800, Yingjie Lan wrote:
Hi everyone,
Variables in Python are resolved dynamically at runtime, which comes at
a performance cost. However, a lot of times we don't need that feature.
Variables can be determined at compile
BartC wrote:
I got the impression the OP was talking about simply pinning down
certain variables, so that a runtime name lookup (if that's in fact what
Python does) was not necessary.
A problem with this is that lexical name lookups are a
relatively small proportion of the looking up that goe
>
> Declaring the *type* of such variables is a different matter I think (and
> probably is not considered 'pythonic'; certainly it's a crude, if effective,
> way of getting extra performance).
I concur. Especially given performance is not a primary goal of Python to
begin with, and--if such a bo
"Steven D'Aprano" wrote in message
news:4d6f26a5$0$30003$c3e8da3$54964...@news.astraweb.com...
On Wed, 02 Mar 2011 19:45:16 -0800, Yingjie Lan wrote:
Hi everyone,
Variables in Python are resolved dynamically at runtime, which comes at
a performance cost. However, a lot of times we don't nee
> Finally, Python 3 introduced type annotations, which are currently a
> feature looking for a reason.
By type annotations, do you mean function annotations (see PEP 3107,
http://www.python.org/dev/peps/pep-3107/)? Or is this some other
feature that I'm unaware of?
Rafe
--
http://mail.python.org
On Wed, 2011-03-02 at 19:45 -0800, Yingjie Lan wrote:
> Hi everyone,
>
> Variables in Python are resolved dynamically at runtime, which comes at a
> performance cost. However, a lot of times we don't need that feature.
> Variables
> can be determined at compile time, which should boost up speed
- Original Message
From: Steven D'Aprano
To: python-list@python.org
Sent: Thu, March 3, 2011 1:27:01 PM
Subject: Re: having both dynamic and static variables
On Wed, 02 Mar 2011 19:45:16 -0800, Yingjie Lan wrote:
> Hi everyone,
>
> Variables in Python are resolved
On Wed, 02 Mar 2011 19:45:16 -0800, Yingjie Lan wrote:
> Hi everyone,
>
> Variables in Python are resolved dynamically at runtime, which comes at
> a performance cost. However, a lot of times we don't need that feature.
> Variables can be determined at compile time, which should boost up
> speed.
Hi everyone,
Variables in Python are resolved dynamically at runtime, which comes at a
performance cost. However, a lot of times we don't need that feature. Variables
can be determined at compile time, which should boost up speed. Therefore, I
wonder if it is a good idea to have static variable
30 matches
Mail list logo