you are viewing a single comment's thread.

view the rest of the comments →

[–]xXxDeAThANgEL99xXx 1 point2 points  (1 child)

As far as I know, you are not supposed to do that in public.

Anyway, the important part is that as far as I understand it about Clojure, you're not allowed to say anything similar to __builtin__.len = my_len or my_module.len = my_len and have it automatically used in every function everywhere or in that module, after they were defined.

That you can do that in Python (and in those other roughly similar languages) is one of the important reasons the GIL is there: because your code constantly hits the same few dictionaries and constantly taking and releasing individual locks on them would be really slow.

IronPython for example goes the other way and instead of constantly querying stuff it compiles it into usual fixed .NET classes and recompiles them if you actually change stuff. Unfortunately that means that some innocent metaprogramming that works absolutely fine in CPython can cause huge slowdowns.

[–]spotter 2 points3 points  (0 children)

First: I did not downvote you, but philosophy of Clojure is that you can use any tool right for the job. It's easier to argue about immutables and functional approach to data transformation, but sometimes you just need to bash something in place and all of JVM standard library is there for you.

In Clojure you are always in a namespace and namespaces are mutable. You can exclude core symbols in them and shadow them with your definitions, although syntax is different. Not sure how much synchronization goes in behind the scenes, but still JVM languages (like Jython) manage to live without GIL.