{"id":736,"date":"2009-06-10T03:37:30","date_gmt":"2009-06-10T02:37:30","guid":{"rendered":"http:\/\/fiber-space.de\/wordpress\/?p=736"},"modified":"2009-06-10T03:37:30","modified_gmt":"2009-06-10T02:37:30","slug":"jython-64k-ought-to-be-enough-for-anybody","status":"publish","type":"post","link":"http:\/\/fiber-space.de\/wordpress\/2009\/06\/10\/jython-64k-ought-to-be-enough-for-anybody\/","title":{"rendered":"Jython &#8211; 64K ought to be enough for anybody"},"content":{"rendered":"<pre lang=\"python\">Jython 2.5rc4 (Release_2_5rc4:6470, Jun 8 2009, 13:23:16)\r\n[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_13\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n&gt;&gt;&gt; L = range(10000)\r\n&gt;&gt;&gt; eval(str(L))\r\nTraceback (most recent call last):\r\n  File \"\", line 1, in\r\njava.lang.ClassFormatError: Invalid method Code length 99894 in class file org\/python\/pycode\/_pyx9\r\n        at java.lang.ClassLoader.defineClass1(Native Method)\r\n        at java.lang.ClassLoader.defineClass(Unknown Source)\r\n        at org.python.core.BytecodeLoader$Loader.loadClassFromBytes(BytecodeLoader.java:116)\r\n        at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:35)\r\n        at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:65)\r\n        ...\r\n        at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:90)\r\n        at org.python.util.jython.run(jython.java:293)\r\n        at org.python.util.jython.main(jython.java:113)\r\n\r\njava.lang.ClassFormatError: java.lang.ClassFormatError: Invalid method Code length 99894 in class file org\/python\/pycode\/_pyx9\r\n&gt;&gt;&gt;<\/pre>\n<p>64K ought to be enough for anybody.<\/p>\n<h4> <\/h4>\n<pre lang=\"ruby\">irb(main):001:0&gt; L = (1...10000).to_a ;nil\r\n=&gt; nil\r\nirb(main):002:0&gt; SL = eval \"[\"+L.join(\",\")+\"]\"; nil\r\n=&gt; nil\r\nirb(main):003:0&gt; SL[10..15]\r\n=&gt; [11, 12, 13, 14, 15, 16]\r\nirb(main):004:0&gt;<\/pre>\n<p>Just to get this straight. It is argued for almost decade that Python cannot have some advanced features ( the whole FP\/Stackless story ) because this would break Jython and Jython is implemented s.t. `eval` is broken and Jython users cannot even import Python data-structures like generated dicts or lists that exceed 64KB. What about backporting this behavior to CPython in order to preserve conformance between implementations?<\/p>\n<p>Note that the Ruby example is JRuby &#8211; not that anyone blames the JVM. Ruby is morally inferior though and wildly coerces types on its own behalf but this is another story.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Jython 2.5rc4 (Release_2_5rc4:6470, Jun 8 2009, 13:23:16) [Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_13 Type &#8220;help&#8221;, &#8220;copyright&#8221;, &#8220;credits&#8221; or &#8220;license&#8221; for more information. &gt;&gt;&gt; L = range(10000) &gt;&gt;&gt; eval(str(L)) Traceback (most recent call last): File &#8220;&#8221;, line 1, &hellip; <a href=\"http:\/\/fiber-space.de\/wordpress\/2009\/06\/10\/jython-64k-ought-to-be-enough-for-anybody\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/fiber-space.de\/wordpress\/wp-json\/wp\/v2\/posts\/736"}],"collection":[{"href":"http:\/\/fiber-space.de\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/fiber-space.de\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/fiber-space.de\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/fiber-space.de\/wordpress\/wp-json\/wp\/v2\/comments?post=736"}],"version-history":[{"count":8,"href":"http:\/\/fiber-space.de\/wordpress\/wp-json\/wp\/v2\/posts\/736\/revisions"}],"predecessor-version":[{"id":1005,"href":"http:\/\/fiber-space.de\/wordpress\/wp-json\/wp\/v2\/posts\/736\/revisions\/1005"}],"wp:attachment":[{"href":"http:\/\/fiber-space.de\/wordpress\/wp-json\/wp\/v2\/media?parent=736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/fiber-space.de\/wordpress\/wp-json\/wp\/v2\/categories?post=736"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/fiber-space.de\/wordpress\/wp-json\/wp\/v2\/tags?post=736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}