Migrating from CPython to Jython

后端 未结 6 455
时光取名叫无心
时光取名叫无心 2020-12-29 04:26

I\'m considering moving my code (around 30K LOC) from CPython to Jython, so that I could have better integration with my java code.

Is there a checklist or a guide

6条回答
  •  天涯浪人
    2020-12-29 04:54

    So far, I have noticed two further issues:

    • String interning 'a' is 'a' is not guaranteed (and it is just an implementation fluke on CPython). This could be a serious problem, and really was in one of the libraries I was porting (Jinja2). Unit tests are (as always) your best friends!
    Jython 2.5b0 (trunk:5540, Oct 31 2008, 13:55:41)
    >>> 'a' is 'a'
    True
    >>> s = 'a'
    >>> 'a' is s
    False
    >>> 'a' == s   
    True
    >>> intern('a') is intern(s)
    True
    

    Here is the same session on CPython:

    Python 2.5.2 (r252:60911, Oct  5 2008, 19:24:49)
    >>> 'a' is 'a'
    True
    >>> s = 'a'
    >>> 'a' is s
    True
    >>> 'a' == s
    True
    >>> intern('a') is intern(s)
    True
    
    
    • os.spawn* functions are not implemented. Instead use subprocess.call. I was surprised really, as the implementation using subprocess.call would be easy, and I am sure they will accept patches.

    (I have been doing a similar thing as you, porting an app recently)

提交回复
热议问题