473,326 Members | 2,175 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

(no subject)

Ype writes:
For the namespaces in Jython this 'Python internal thread safety'
is handled by the Java class:

http://www.jython.org/docs/javadoc/o...StringMap.html

which has almost all of it public methods Java synchronized:

http://cvs.sourceforge.net/viewcvs.p...re/PyStringMap.
java
Thinking about it: is this the Jython parallel of CPython's
Global Interpreter Lock, the famous GIL?


No.

The GIL has the unfortunate disadvantage that it prevents multiple
processor machines (or other modern architechures) from processing
multiple bytecodes simultaneously in different threads. Jython does
not have this limitation.

-- Michael Chermside
Jul 18 '05 #1
4 4462
Michael Chermside wrote:
The GIL has the unfortunate disadvantage that it prevents multiple
processor machines (or other modern architechures) from processing
multiple bytecodes simultaneously in different threads. Jython does
not have this limitation.


Michael,

That's the first definitive statement I've ever read about Jython not
being limited by a GIL on multi-processor machines.

Would the following statements be correct?

1. CPython has a Global Interpreter Lock (GIL), which allows only one
thread to execute python code at a time. This "macro-level" of locking
was chosen because empirical evidence from experimental
implementations (a long time ago, in a galaxy far, far, away) showed
that it gave better performance than approaches using more
fine-grained locking, i.e. object-level locking.

2. Jython is implemented on top of java, which has built-in support
for fine-grained locking of individual objects. Therefore, the jython
implementers chose not to use a GIL, but instead to rely on the
fine-grained locking facilities of the Java platform to protect object
integrity. So jython programs support simultaneous execution of
multiple jython threads on multiple processors (obviously assuming the
Java VM on which it is running is capable of migrating threads to
other processors).

I know I could find out the answer to this question by going directly
to the jython source, but I unfortunately don't have the time. Also, I
don't actually *need* to know the answer, since I haven't yet needed
the horsepower of a mutli-processor box. But the question is
theoretically interesting, and probably of practical interest to many
readers of c.l.py.

And if the above statements are true, then I'm sure we're going to see
an interesting discussion of why fine-grained locking is fast enough
in java, but not fast enough in C >;-)

regards,

--
alan kennedy
-----------------------------------------------------
check http headers here: http://xhaus.com/headers
email alan: http://xhaus.com/mailto/alan
Jul 18 '05 #2
Alan Kennedy wrote:

Would the following statements be correct?
1. [snip]
2. Jython is implemented on top of java, which has built-in support
for fine-grained locking of individual objects. Therefore, the jython
implementers chose not to use a GIL, but instead to rely on the
fine-grained locking facilities of the Java platform to protect object
integrity.


You seem to think there is a "Jython runtime interpreter" in the same
way there is one for CPython... Are you aware that Jython compiles
your Python source to Java bytecode?

-Peter
Jul 18 '05 #3
Alan Kennedy:
Would the following statements be correct?

1. CPython has a Global Interpreter Lock (GIL), which allows only one
thread to execute python code at a time. This "macro-level" of locking
was chosen because empirical evidence from experimental
implementations (a long time ago, in a galaxy far, far, away) showed
that it gave better performance than approaches using more
fine-grained locking, i.e. object-level locking.


I suspect it was done first because it was the easiest to do. Then
there was the free-threaded version, which provided the empirical
evidence.

Andrew
da***@dalkescientific.com
Jul 18 '05 #4
[Alan Kennedy]
Jython is implemented on top of java, which has built-in support
for fine-grained locking of individual objects. Therefore, the jython
implementers chose not to use a GIL, but instead to rely on the
fine-grained locking facilities of the Java platform to protect object
integrity.

[Peter Hansen] You seem to think there is a "Jython runtime interpreter" in the same
way there is one for CPython... Are you aware that Jython compiles
your Python source to Java bytecode?


Compiles it to Java bytecode, which makes calls against a python
runtime which has been implemented in Java .....

All calls into the jython runtime require that the code execution be
associated with a PySystemState object, which keeps track of
"interpreter state" for the context in which the code is running
.......

http://www.jython.org/docs/javadoc/o...stemState.html

So jython bytecode *is* executed by a jython interpreter, which is an
interpreter in all but name ......

The last link in the chain is the PythonInterpreter object, which
wraps the above, and provides some simple services to simplify using
the "interpreter".

http://www.jython.org/docs/javadoc/o...terpreter.html

From what I can see, jython has pretty much, class for class, the same
structure as the cpython interpreter .....

--
alan kennedy
-----------------------------------------------------
check http headers here: http://xhaus.com/headers
email alan: http://xhaus.com/mailto/alan
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: gsb | last post by:
HOW TO: Submit a form to PHP with no return? I need to submit a form for file upload to a PHP script but do not want anything returned. That is the TARGET for the form should be like a null...
1
by: Jeff Sandys | last post by:
Can you include a subject with sendmail using smtplib? When I do this (names changed to protect the innocent): import smtplib toadr = "me@myisp.com" frmadr = "myhost@myhost.com" msg = "this...
3
by: Gert-Jan van Middelkoop | last post by:
Hi, I'm using an e-mailform on my website. I would like to make a dropdownmenu with several subjects, so when the e-mail arrives I can immediatly see it's subject. Therefore, this code must...
6
by: Susan | last post by:
Is there any way to take one of the fields from the form and use that as your subject line.. right now I have a default subject line entered - but would rather have the subject be the information...
1
by: kamlai | last post by:
I've written the following codes to include utf-8 wordings in both the subject and the content. $headers = "MIME-Version: 1.0\r\n". "Content-type: text/plain; charset=utf-8\r\n". "From:...
3
by: Laangen_LU | last post by:
Dear Group, my first post to this group, so if I'm on the wrong group, my apologies. I'm trying to send out an email in Chinese lanuage using the mail() function in PHP. Subject and...
3
by: b. dougherty | last post by:
Greetings all- I am trying to extract subject headers from emails that have been saved as text files. The subject headers are in MIME UTF-8 format, and so they appear like this: subject:...
4
by: Alec MacLean | last post by:
Is anyone aware of a size limit imposed on the subject text when using the System.Net.Mail library? I'm getting problems of message not being recieved if the subject exceeds 15 chars. Thx
7
by: plumba | last post by:
I am working on a html form for work, I need to make the Subject of the email which the form produces to be unique each time. The subject is currently hard coded in, in the format of:<form...
5
by: Alan Isaac | last post by:
I have two questions about the "observer pattern" in Python. This is question #1. (I'll put the other is a separate post.) Here is a standard example of the observer pattern in Python:
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.