having both dynamic and static variables

Westley Martínez anikom15 at gmail.com
Thu Mar 3 09:19:41 EST 2011


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. Therefore, I 
> wonder if it is a good idea to have static variables as well. So at compile 
> time, a variable is determined to be either static  or dynamic (the reference of 
> a static varialbe is determined at compile time -- the namespace implementation 
> will consist of two parts, a tuple for static variables and a dict for dynamic 
> ones). The resolution can be done at the second pass of compilation. By default, 
> variables are considered static. A variables is determined dynamic when: 1. it 
> is declared dynamic; 2. it is not defined locally and the nearest namespace has 
> it declared dynamic. A static variable can't be deleted, so a deleted variable 
> must be a dynamic one: we can either enforce that the variable must be 
> explicitly declared or allow a del statement to implicitly declare a dynamic 
> variable.
> 
> Any thoughts?
> 
> Yingjie
> 
> 
> 
>       
I once used this obscure language called "C"; it did kind of what you're
talking about.




More information about the Python-list mailing list