4 ms·
> Nobody uses that stuff in production code Nobody uses the features of Python which make it a dynamic language? Google must write some really weird Python if
by TillE 10y ago
> Nobody uses that stuff in production code
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.
- azinman2 10y agoTheir python is weird if it doesn't use eval?
- coldtea 10y ago>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...
- Animats 10y agoIn 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.
- mdaniel 10y ago> 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 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" :-)
- masklinn 10y agoRPython is a restricted (hence R) language specifically for VM development, it is not a general-purpose language.
- weberc2 10y agoI'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).
- bjt 10y agoAnybody 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.
- orf 10y ago'exec' and 'eval'? No it's not, the importlib machinery is used (which doesn't just eval(read('import.py')))
- earthboundkid 10y agoI 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.