Hey good people,
I've been doing a lot of simultaneous Jython and CPython programming lately,
and just wanted to say, with no intended ill will toward any of the
individuals who have been generous enough to make the two languages
possible, that, well, they're kinda different.
I guess it was inevitable, but with Jython stuck at Python 2.1, it's not
really the same language as CPython is today. You still have to type "from
__future__ import nested_scopes", and there are no generators or properties,
and the type/class dichotomy is still in that awkward state, and you have to
inherit from UserList/Dict, and there are no sets, and you have to roll your
own enumerate() and dict(), and files don't close themselves automatically
(yeah, I know, dream on, hehe...), no csv module, no importing from zips...
wow... it's amazing where CPython has come in such a short time. Well, anyway.
I've never tried the 2.2a0 version (of Jython), mostly because the message
on the site about it being somewhere between 2.1 and 2.3 left me a bit
uncomfortable. ;)
Jython is still a dream to program in compared to Java. So I can't complain.
But it's frozen in a particular state, while CPython is continuing to
aggressivly pursue new ground--like lazy iteration--in ways that change the
Python style; ways that leave me re-implenting not-so-cool versions of the
new style for Jython. In a sense, it's made me really think hard about what
new Python features are really useful, and what are merely new. I definitely
like having the enumerate() function around. And dict(), how could you live
without a complement to dict.items? That should have been in Python -1.0. =)
Is there anyone here that works on Jython? Do you need help? What kind of
help do you need? What's your estimation of the amount of work needed? Is
the work done with PyPy helpful? I'm really curious.
One Love.
One Python.
That sounds dirty.
Dave
--
..:[ dave benjamin (ramenboy) -:- www.ramenfest.com -:- www.3dex.com ]:.
: d r i n k i n g l i f e o u t o f t h e c o n t a i n e r : 6 2108
Dave Benjamin <ra***@lackingt alent.com> writes:
[...] Is there anyone here that works on Jython? Do you need help? What kind of
They certainly need help.
help do you need? What's your estimation of the amount of work needed? Is
Asking on the Jython list seems like a good idea.
the work done with PyPy helpful? I'm really curious.
PyPy is a research effort, so not immediately useful. It may have big
payoffs if successful, of course.
John
In article <87************ @pobox.com>, John J. Lee wrote: Dave Benjamin <ra***@lackingt alent.com> writes: [...] Is there anyone here that works on Jython? Do you need help? What kind of
They certainly need help.
I suppose that was a redundant question. =) help do you need? What's your estimation of the amount of work needed? Is
Asking on the Jython list seems like a good idea.
Yes. But I think that c.l.p is an appropriate place to bring this issue up
in general, because if CPython and Jython are truly--as they are often
represented in books and tutorials--just two implementations of the Python
language, we all ought to be more concerned with unifying them. I never see
Jython advertised as a limited subset of Python. the work done with PyPy helpful? I'm really curious.
PyPy is a research effort, so not immediately useful. It may have big payoffs if successful, of course.
Well, my thinking is that, since it's an implementation of Python written in
Python, many of the new features of CPython that don't require syntactical
or fundamental object-model changes could be ported from PyPy to Jython as a
temporary fix, to be eventually recoded in Java.
--
..:[ dave benjamin (ramenboy) -:- www.ramenfest.com -:- www.3dex.com ]:.
: d r i n k i n g l i f e o u t o f t h e c o n t a i n e r :
Dave Benjamin <ra***@lackingt alent.com> writes: In article <87************ @pobox.com>, John J. Lee wrote: Dave Benjamin <ra***@lackingt alent.com> writes: [...] Is there anyone here that works on Jython? Do you need help? What kind of They certainly need help.
I suppose that was a redundant question. =)
Yes, but it has been specifically noted by GvR (as well as the
Jythonistas) that Jython is lacking developers ATM. help do you need? What's your estimation of the amount of work needed? Is
Asking on the Jython list seems like a good idea.
Yes. But I think that c.l.p is an appropriate place to bring this issue up in general, because if CPython and Jython are truly--as they are often
Sure. But the questions you asked can probably be best answered by
the core Jython people.
represented in books and tutorials--just two implementations of the Python language, we all ought to be more concerned with unifying them. I never see Jython advertised as a limited subset of Python.
Well, it's *not* a limited subset of CPython 2.1 (apart from tiny
differences).
[...] PyPy is a research effort, so not immediately useful. It may have big payoffs if successful, of course.
Well, my thinking is that, since it's an implementation of Python written in Python, many of the new features of CPython that don't require syntactical or fundamental object-model changes could be ported from PyPy to Jython as a temporary fix, to be eventually recoded in Java.
Library changes don't require PyPy, they already work (most of the
time) direct from CPython. It's the fundamentals that take the work.
I'm not sure whether there's a third category, as you suggest.
I believe GvR said that PyPy might (might!) become a sort of
executable standard for Python in the future, though.
John
In article <87************ @pobox.com>, John J. Lee wrote: Yes, but it has been specifically noted by GvR (as well as the Jythonistas) that Jython is lacking developers ATM.
I see. represented in books and tutorials--just two implementations of the Python language, we all ought to be more concerned with unifying them. I never see Jython advertised as a limited subset of Python.
Well, it's *not* a limited subset of CPython 2.1 (apart from tiny differences).
True. I suppose this brings up the following question: What *is* "Python"?
Does the concept of Python *today* fit within Jython's feature set? I'd say
much of it does, but a few things stick out, in order of decreasing
importance (IMHO):
- generators
- properties
- getattr/getitem behavior (which is even different from CPython 2.1)
- type factories being classes
- dictionary support for "in" keyword
When I think of the Python language, as it stands today, I am tempted to
include all of the above.
I recently ported Python 2.3's "sets" module. I posted a patch here
recently, although I've improved it somewhat and fixed a few bugs
since then. The lack of an "itertools" module was perhaps my biggest
obstacle (the "for key in adict" feature was another common one). Now, I
suppose I could have tried to port "itertools" , but there's no "yield", so
how do I do that? I ended up just using the old map and filter functions,
which means all of that code is back to the old Python memory efficiency. > PyPy is a research effort, so not immediately useful. It may have big > payoffs if successful, of course.
Well, my thinking is that, since it's an implementation of Python written in Python, many of the new features of CPython that don't require syntactical or fundamental object-model changes could be ported from PyPy to Jython as a temporary fix, to be eventually recoded in Java.
Library changes don't require PyPy, they already work (most of the time) direct from CPython. It's the fundamentals that take the work. I'm not sure whether there's a third category, as you suggest.
Sometimes they do, sometimes they don't. But the list of things that you
can't do in library code if you want to be compatible with Jython 2.1 is
growing. For instance, the "str.join" trick that has been discussed recently
won't work in Jython 2.1 since "str" is not a class. It's a minor thing, but
I bet a lot of people aren't aware of that. Little things like that can add
up.
I've never looked at the code to PyPy, so this is purely speculative, but it
seems like at least a plausible idea to provide an extension mechanism for
Jython such that PyPy code can be incorporated. Imagine if you could add the
"yield" keyword by just importing a pure-Python module. I suppose we'd be
entering macro-like territory, so it'd be controversial.. .
I believe GvR said that PyPy might (might!) become a sort of executable standard for Python in the future, though.
I think that's an impressive idea, but it almost seems like the resources
spent in keeping PyPy and CPython in parallel could be better spent keeping
Jython and CPython in parallel, seeing as nobody is calling PyPy "Python"
currently.
I will check out the Jython list.
Peace,
Dave
--
..:[ dave benjamin (ramenboy) -:- www.ramenfest.com -:- www.3dex.com ]:.
: d r i n k i n g l i f e o u t o f t h e c o n t a i n e r :
On Fri, Jan 09, 2004 at 11:11:36PM -0000, Dave Benjamin wrote: In article <87************ @pobox.com>, John J. Lee wrote: Yes, but it has been specifically noted by GvR (as well as the Jythonistas) that Jython is lacking developers ATM. I see.
represented in books and tutorials--just two implementations of the Python language, we all ought to be more concerned with unifying them. I never see Jython advertised as a limited subset of Python.
Well, it's *not* a limited subset of CPython 2.1 (apart from tiny differences).
True. I suppose this brings up the following question: What *is* "Python"? Does the concept of Python *today* fit within Jython's feature set? I'd say much of it does, but a few things stick out, in order of decreasing importance (IMHO):
- generators
All generators can be re-written with classes using the iterator protocol.
Here's a simple example:
# As a generator
def foogen():
yield 1
yield 'a'
yield []
# As classes using the iterator protocol
class _FooGenIterator :
counter = 0
def next(self): return getattr(self, 'state_%d' % self.counter)()
def state_0(self): return 1
def state_1(self): return 'a'
def state_2(self): return []
def state_3(self): raise StopIteration
class FooGen:
def __iter__(self):
return _FooGenIterator ()
# Used exactly the same
for i in foogen(): print i
for j in FooGen(): print j
- properties
This is getting closer, I think. More generator, descriptors are pretty
honkin' fundamental these days. On the other hand, most behavior
acheivable with properties can be achieved with __g/setattr__, albeit it
quite as conveniently.
- getattr/getitem behavior (which is even different from CPython 2.1)
I guess I haven't used Jython enough to know what's going on here.
- type factories being classes
This seems pretty important to me, probably the most important on the
list. Metaclasses existed before 2.2, but not without writing an extension
module.
- dictionary support for "in" keyword
This seems pretty trivial to me. It's just a transformation of
dict.has_key().
[snip]
I believe GvR said that PyPy might (might!) become a sort of executable standard for Python in the future, though.
I think that's an impressive idea, but it almost seems like the resources spent in keeping PyPy and CPython in parallel could be better spent keeping Jython and CPython in parallel, seeing as nobody is calling PyPy "Python" currently.
Can't say I agree here, probably because I don't much care about Java ;)
I think PyPy has a lot more bang for the buck for your average Python
programmer. Jython might be nice to bring in some of the Java people, or
make some of that Java work easier when you absolutely have to use it, but
for your average Python application, it hardly enters into the picture.
PyPy, on the other hand opens up a lot of possibilities for future
improvements to the language (because it is easier to prototype new features
in Python than in C) as well as improvements to existing features.
Jp
In article <ma************ *************** ***********@pyt hon.org>, Jp Calderone wrote: All generators can be re-written with classes using the iterator protocol. Here's a simple example:
Thanks for the nice example. Unfortunately:
Jython 2.1 on java1.4.2_01 (JIT: null)
Type "copyright" , "credits" or "license" for more information. execfile('your-nice-example.py') for j in FooGen(): print j
....
Traceback (innermost last):
File "<console>" , line 1, in ?
AttributeError: __getitem__
Bring back any memories of the days before generators? ;) - properties
This is getting closer, I think. More generator, descriptors are pretty honkin' fundamental these days. On the other hand, most behavior acheivable with properties can be achieved with __g/setattr__, albeit it quite as conveniently.
Yes, but from my experience the property() builtin is so much more
convenient than __get/setattr__ that I am much more likely to use properties
in CPython. With Jython, I have to overcome my laziness, since it means
writing a fair bit of boilerplate. (example follows) - getattr/getitem behavior (which is even different from CPython 2.1)
I guess I haven't used Jython enough to know what's going on here.
Here's an example. I sometimes find it useful to create dictionaries that
allow either attribute or item access, a la JavaScript/ActionScript. In
CPython, I can use the (comment to a) recipe from ASPN:
class attrdict(dict):
def __getattr__(sel f, name):
return self[name]
def __setattr__(sel f, name, value):
self[name] = value
(http://aspn.activestate.com/ASPN/Coo...n/Recipe/52313)
This seems like it would be a very simple port to Jython, right? It's
actually a bit hairy. In order to get it to work, I had to do the following:
class attrdict(UserDi ct):
"Dictionary that allows keys to be used as object attributes."
def __init__(self, dict=None, **kwds):
"""attrdict () constructor (behaves like Python 2.3's dict()).
Optionally takes a source dictionary or keyword arguments."""
if hasattr(dict, 'items'):
UserDict.__init __(self, dict)
else:
UserDict.__init __(self)
if dict is not None:
for key, value in dict:
self[key] = value
if kwds:
self.update(kwd s)
def __getattr__(sel f, name):
if self.__dict__.h as_key(name):
raise AttributeError, name
elif name == '__members__':
return self.keys()
elif name.startswith ('__') and name.endswith(' __'):
raise AttributeError, name
else:
return self[name]
def __setattr__(sel f, name, value):
if name == 'data':
self.__dict__[name] = value
else:
self[name] = value
def __delattr__(sel f, name):
del self[name]
Whew! Now we're rolling with any version of CPython or Jython 2.1 and up. I
wish I could explain to you how much I had to screw with this to get it to
work. It turns out that the constructor for UserDict tries to create an
attribute called "data", which calls my custom __setattr__, and it gets
stuck in an infinite loop. Many combinations and stack exceptions later, I
finally got what used to be a five-line class working in Jython.
Now, I hope you understand why I'm more privy to properties in CPython. =) - type factories being classes
This seems pretty important to me, probably the most important on the list. Metaclasses existed before 2.2, but not without writing an extension module.
Hmmm... well, metaclasses would be nice, too, but mostly I was thinking of
whether you subclass "dict" or "UserDict" or "types.DictType ", and whether
or not things like "str.join" are available. The former, as you can see, can
make a big difference in how you code things. The latter isn't so significant. - dictionary support for "in" keyword
This seems pretty trivial to me. It's just a transformation of dict.has_key().
Yep, and there were many such transformations I had to hunt down and fix by
hand when trying to port the "sets" module. A pretty small module, too. It
was error-prone, and I actually missed a serious performance error when I
posted the patch to c.l.p. If anyone is interested, I can post a better
patch, or just send you the file (contact me by email - r!a@m#e%n AT
r^a@m#e&n!f@e&s #t PUNTO com - remove the line noise of course).
> I believe GvR said that PyPy might (might!) become a sort of > executable standard for Python in the future, though.
I think that's an impressive idea, but it almost seems like the resources spent in keeping PyPy and CPython in parallel could be better spent keeping Jython and CPython in parallel, seeing as nobody is calling PyPy "Python" currently.
Can't say I agree here, probably because I don't much care about Java ;) I think PyPy has a lot more bang for the buck for your average Python programmer. Jython might be nice to bring in some of the Java people, or make some of that Java work easier when you absolutely have to use it, but for your average Python application, it hardly enters into the picture. PyPy, on the other hand opens up a lot of possibilities for future improvements to the language (because it is easier to prototype new features in Python than in C) as well as improvements to existing features.
Well, I have to admit I'm a bit biased. I work in a Java team, and I've been
trying to incorporate Python into the existing infrastructure for the past
year or so. So, personally, I'm not the world's biggest Java fan, and I find
PyPy much more interesting, but Jython has more immediate usefulness.
However, I do find myself doing a lot of extra work to keep my code portable
between Jython and CPython, since it facilitates reuse.
I agree that PyPy presents new possibilities for language experimentation ,
and being a total language nerd myself, I'm all for it. =)
However, I just want to make the point that Jython is becoming less and less
"Python" as the evolution of CPython begins to affect the actual style in
which Python code is written. And this makes the popular claim, that Python
is the language, and CPython and Jython are two implementations , a bit
misleading.
But it's a lot easier to complain than to contribute. That I'll readily
admit. =)
Thanks,
Dave
--
..:[ dave benjamin (ramenboy) -:- www.ramenfest.com -:- www.3dex.com ]:.
: d r i n k i n g l i f e o u t o f t h e c o n t a i n e r : This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: bezeee |
last post by:
At my work we are in the process of building a tool to test an XML based
API. Basically, XML in and XML out over http. Currently, there are two
engines that do all of the schema validations, xml diffs, sending/receiving,
etc. One of these engines in implemented in C# and the other in Java.
Now the choice comes down to which scripting language we choose (Perl,
Python or Jython) to tie into one of these engines. The scripting language...
|
by: mike420 |
last post by:
I think everyone who used Python will agree that its syntax is
the best thing going for it. It is very readable and easy
for everyone to learn. But, Python does not a have very good
macro capabilities, unfortunately. I'd like to know if it may
be possible to add a powerful macro system to Python, while
keeping its amazing syntax, and if it could be possible to
add Pythonistic syntax to Lisp or Scheme, while keeping all
of the...
|
by: Stephen C. Waterbury |
last post by:
This seems like it ought to work, according to the
description of reduce(), but it doesn't. Is this
a bug, or am I missing something?
Python 2.3.2 (#1, Oct 20 2003, 01:04:35)
on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> d1 = {'a':1}
>>> d2 = {'b':2}
>>> d3 = {'c':3}
|
by: vincent Salaun |
last post by:
hi all,
here's my problem :
I've embedded a python interpreter in our java application (based on the
NetBeans palteforrm) using the Jython API :
http://www.jython.org/docs/javadoc/index.html
So, i've used the PythonInterpreter class to instanciate an interpreter
and to integrate it but the its environnement doesn't seem to be the
|
by: Ramza Brown |
last post by:
I know you may frown at my use at java, but this is a pretty simple way
to create GUIs quickly, using Java's swing. I have some code for an
approach for integrating the swing GUI components and python. I threw
the project together in a couple of days, so it is not some massive
application. And, I have some little models(hehe). Anyway, if you want
to check out an approach for working with Jython, here it is.
Some questions, I do get...
| |
by: WaterWalk |
last post by:
I've just read an article "Building Robust System" by Gerald Jay
Sussman. The article is here:
http://swiss.csail.mit.edu/classes/symbolic/spring07/readings/robust-systems.pdf
In it there is a footprint which says:
"Indeed, one often hears arguments against building exibility into an
engineered sys-
tem. For example, in the philosophy of the computer language Python it
is claimed:
\There should be one|and preferably only one|obvious...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |