5 ms·
Of course. http://codepad.org/3fWweqje http://codepad.org/3fWweqje
by oinksoft 15y ago
Of course.
http://codepad.org/3fWweqje http://codepad.org/3fWweqje
- deleted 15y ago[deleted]
- emehrkay 15y agoCan it be done for built-in types?
- maaku 15y agoNo, unfortunately. That's one thing both Ruby and JS have over Python.
- oinksoft 15y agoNo, it can't, at least not in CPython. You can import __builtin__ and clobber str, for instance, but that will not affect the behavior of existing strings, nor will it influence the behavior of string literals. It's something that can be done in Ruby and JavaScript, but I believe it was never allowed in Python in the name of performance (you incur overhead when every number is Fixnum with the same lookup rules as any other instance, for example), and also safety.