Y
Yingjie Lan
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
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