This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ jython27 -Dpython.security.respectJavaAccessibility=false | |
Jython 2.7b3+ (default:68aaff268c3c, Sep 10 2014, 20:03:31) | |
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.7.0_21 | |
>>> from org.python.tests import Invisible | |
>>> dir(Invisible) | |
['EXTRA_ARG_PUBLIC_METHOD', 'EXTRA_ARG_PUBLIC_STATIC_METHOD', 'OVERLOADED_EXTRA_ARG_PUBLIC_METHOD', 'OVERLOADED_PROTECTED_METHOD', 'OVERLOADED_PUBLIC_METHOD', 'OVERLOADED_PUBLIC_STATIC_METHOD', 'OVERLOADED_STATIC_METHOD', 'PACKAGE_FIELD', 'PACKAGE_METHOD', 'PACKAGE_STATIC_FIELD', 'PACKAGE_STATIC_METHOD', 'PROTECTED_FIELD', 'PROTECTED_METHOD', 'PROTECTED_STATIC_FIELD', 'PROTECTED_STATIC_METHOD', 'PUBLIC_FIELD', 'PUBLIC_METHOD', 'PUBLIC_METHOD_FIELD', 'PUBLIC_STATIC_FIELD', 'PUBLIC_STATIC_METHOD', 'PUBLIC_STATIC_METHOD_FIELD', 'SUBCLASS_OVERLOAD', 'SUBCLASS_OVERRIDE', 'SUBCLASS_STATIC_OVERLOAD', 'SUBCLASS_STATIC_OVERRIDE', 'SUBVISIBLE_SHARED_NAME_FIELD', 'UNUSED', 'VISIBLE_SHARED_NAME_FIELD', '__class__', '__copy__', '__deepcopy__', '__delattr__', '__doc__', '_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from array import array | |
from jarray import zeros | |
from java.nio import ByteBuffer, CharBuffer | |
from java.nio.charset import Charset, CodingErrorAction # FIXME actually use CodingErrorAction | |
shift_jis = Charset.forName("Shift_JIS") | |
decoder = shift_jis.newDecoder() | |
jis_data = open("shift_jis.txt", "rb").read() # data encoded in shift_jis format | |
utf_8_data = open("shift_jis-utf8.txt", "rb").read() # same data, encoded as utf-8 | |
input_buffer = ByteBuffer.wrap(array("b", jis_data)) # FIXME break into chunks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
392a393 | |
> jython = sys.platform.startswith("java") | |
397d397 | |
< import gc | |
399d398 | |
< import errno | |
427a427,439 | |
> elif jython: | |
> import errno | |
> import threading |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[exec] 355 tests OK. | |
[exec] 13 tests skipped: | |
[exec] test__osx_support test_commands test_crypt test_curses test_dbm | |
[exec] test_lib2to3 test_pickle test_pipes test_readline test_smtpnet | |
[exec] test_subprocess test_urllib2net test_urllibnet | |
[exec] 8 skips unexpected: | |
[exec] test__osx_support test_commands test_crypt test_dbm test_lib2to3 | |
[exec] test_pickle test_pipes test_readline | |
[exec] 17 tests failed: | |
[exec] test_asynchat test_asyncore test_binascii test_dumbdbm test_gzip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
from java.util.concurrent import ArrayBlockingQueue | |
class GreenletExit(Exception): | |
pass | |
# Consider two greenlets, which we will name alice and bob. Some code | |
# is running in the context of alice, then it calls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
from better.baz.package import ImprovedBar | |
class Foo(ImprovedBar): | |
... | |
except ImportError: | |
from ok.baz.package import ImprovedBar | |
class Foo(Bar): | |
... | |
# class Foo is now available, but Clamp in general cannot make both available |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cp test_socket.py dist/Lib/test/. && dist/bin/jython dist/Lib/test/test_socket.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ jython27 | |
Jython 2.7b1+ (default:6e438088c0e3, Feb 10 2014, 11:00:25) | |
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.7.0_21 | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> from java.util import HashMap | |
>>> x = {"a": 42, "b": None} | |
>>> y = HashMap(x) | |
>>> y | |
{b=null, a=42} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import glob | |
import os | |
import sys | |
def main(): | |
cwd = os.getcwd() | |
print ":".join(os.path.normpath(os.path.join(cwd, path)) for path in sys.argv[1:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ab -k -c 10 -n 5000 localhost:8080/ | |
This is ApacheBench, Version 2.3 <$Revision: 655654 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking localhost (be patient) | |
Completed 500 requests | |
Completed 1000 requests | |
Completed 1500 requests | |
Completed 2000 requests |