In Python, you can get at a variable, or even code, in another thread with "getattr()". You can monkey-patch another thread while it is running. This is not very useful, but it's easy to implement in a naive interpreter such as CPython. Part of the price for this is the Global Interpreter Lock, so you don't really have two threads running at once. PyPy has a huge amount of machinery so that stuff will work.
Grumpy doesn't even seem to try to implement that. That's a good thing. If you restrict Python a little, it's much easier to compile.
> That's a good thing. If you restrict Python a little, it's much easier to compile.
Isn't that more or less what RPython does? https://rpython.readthedocs.io/en/latest/architecture.html I mean, I know that starting with a full-fledged(?) Py27 codebase rules out _actually_ using RPython for the stated goals of Grumpy, but I think the two projects agree in principle and differ about the definition of "restricted" :-)
RPython is a restricted (hence R) language specifically for VM development, it is not a general-purpose language.
>Nobody uses the features of Python which make it a dynamic language?
Python has TONS of dynamicity besides those (eval and co), who are seldom used by anyone anyway....
If you think eval is what makes Python dynamic you're doing it wrong...
I'm not sure what is meant by "dynamic language" in that sentence, but examining the compiler output, it supports the features of Python which I think of when I think of "dynamic language" (e.g., a class `Foo` gets compiled into a runtime `*Object` with collections of properties and methods, not into a `type Foo struct` with fixed fields and methods).
Anybody running Django uses this. It uses the pattern of specifying plugins as class paths in strings in the config, which are then looped over and instantiated at runtime.
Frameworks do lots of such dynamic tricks in order to provide nice DSLs for building apps.
'exec' and 'eval'? No it's not, the importlib machinery is used (which doesn't just eval(read('import.py')))
Re:Grumpy: Go running Python
by earthboundkid on Wednesday January 04, 2017 @11:14PM
(#13324684)
I have never used exec or eval in production Python, and I doubt I could get them past code review because of the possible security impact.
Their python is weird if it doesn't use eval?
or getattr/setattr, or dynamically building classes with type(), or probably more features I can't remember now.
Nobody uses the features of Python which make it a dynamic language? Google must write some really weird Python if their compiler is that strict.