I sure hope it's changed for Python 3.0. The FAQ reason for the current
implementation was vague about the processors which were/are the
problem. I'm guessing it is an antiquated artifact of limitations in
shell line processors. Yuck!
-----Original Message-----
From: python-ideas-bounces(a)python.org
[mailto:python-ideas-bounces@python.org] On Behalf Of Steven Bethard
Sent: Monday, October 01, 2007 2:18 PM
To: Python-Ideas
Subject: Re: [Python-ideas] raw strings
On 10/1/07, Clark …
[View More]Maurer <cmaurer(a)slickedit.com> wrote:
> The current implementation doesn't allow for a trailing backslash in
the
> string.
I believe that will change in Python 3.0.
The discussion is here:
http://mail.python.org/pipermail/python-3000/2007-May/007684.html
And Ron Adam's current patch is here:
http://bugs.python.org/issue1720390
STeVe
--
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
--- Bucky Katt, Get Fuzzy
_______________________________________________
Python-ideas mailing list
Python-ideas(a)python.org
http://mail.python.org/mailman/listinfo/python-ideas
[View Less]
Ok. Thanks for letting me know. Call me Clark. I go by my middle name. I need to change my yahoo account.
Does the implementation you describe do the following:
1. Can it be used in per file type of operation (i.e. reload a file of code). It sounds like it can.
2. Will it update variables containing pointers to functions and pointers to methods. As long as the function/method data is being modified in place, this algorithm will work.
----- Original Message ----
From: Greg Ewing <greg.…
[View More]ewing(a)canterbury.ac.nz>
To: python-ideas(a)python.org
Sent: Sunday, September 30, 2007 9:11:38 PM
Subject: Re: [Python-ideas] Enhance reload
Joseph Maurer wrote:
> Please shot this down this high level implementation if it
> won't work in the current code base.
Joseph, you're going to have to learn more about how Python
works if you want to take this any further. It's not really
possible to discuss it in terms as high-level as this. You're
making some assumptions about the overall structure that
aren't really true.
There is an approach that might work, but it's rather
different. Instead of trying to load the new code directly
into the old module, load it into a new, temporary module
and then compare the contents of the two, transferring
selected parts where appropriate.
--
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | Carpe post meridiem! |
Christchurch, New Zealand | (I'm not a morning person.) |
greg.ewing(a)canterbury.ac.nz +--------------------------------------+
_______________________________________________
Python-ideas mailing list
Python-ideas(a)python.org
http://mail.python.org/mailman/listinfo/python-ideas
____________________________________________________________________________________
Got a little couch potato?
Check out fun summer activities for kids.
http://search.yahoo.com/search?fr=oni_on_mail&p=summer+activities+for+kids&…
[View Less]
Ok, my idea of a temporary "replace" attribute wrapped around a reload-like function is not a good idea for Python given that things can be dynamically added to modules at any time.
---------------------------------------
Here is my original high level design:
The way I implemented this feature in Slick-C is with indirection. In Python terms, this means that a separate data structure that isn't reference counted holds the method/function object data. The method/function object is changed to …
[View More]just contain a pointer to it. The data structure which holds all method/function data should probably be a non-reference counted dictionary. When a function is deleted, it's name remains in the dictionary but the entry needs to be changed to indicate that it is "null/invalid". When a deleted function is called, an exception should be raised. Adding a function/method means replacing the data in the dictionary. This type of implementation is simple. There's an insignificant amount of overhead on a function/method call (i.e. instead of "func->data" you have "func=*pfunc;if ( func->isInvalid() ) throw exception; else func->data" ).
Technically this algorithm leaks memory since deleted functions/methods are never removed. My response is who cares. When the interpreter cleanup everything function is called, you simple deallocate everything in the dictionary.
---------------------------------
Instead of a temporary "replace" attribute wrapped into a reload-like call, how about giving modules a user settable "replace" attribute. At any time, the user can set/reset this attribute. This would specify how the user wanted functions/methods processed. Always added or always replaced. The "replace" attribute would likely need to be pass through to function objects, class objects, and method objects. For the macro language scenarios, I would just mark every module that got loaded with this attribute.
The proposed implementation I have given is intended to by very "file" oriented (which maps to a Python module).
Would this work in the current code base?
I'm assuming the following:
When a function is added/executed, the module structure is accessible.
When a class is added (i.e. class myclass), the module structure is accessible.
When a method is added/executed, at least the class structure is accessible?
I hope you see where I'm going here. The executed "class myclass" code which defines a new class can copy the module "replace" attribute. the executed "def myfunction" code which defines a new method can copy the class "replace" attribute.
The function/method object structure could remain the same except for the addition of a new function/method pointer member.
The additional code for a function call would look like this:
// Did this function get defined in "replace" mode?
if ( func->doReplace() ) {
// For this one, use the indirect pointer and not the other member data.
func= func->pfunc;
if ( !func->isValid() ) {
throw exception. // Python exeception, not C++ exception
return here...
}
}
// Now do what we used to do
Given the OO nature of Python, a separate function/method type for a replacable function/method could be defined but I suspect it isn't worth the effort. The above psuedo code is very efficient "doReplace" would probably be just a boolean/int member. The "isValid" called would be efficient as well.
One thing my proposed implementation does not cover is adding new data members to a class. I think it is acceptable for this not to be handled.
Please shot this down this high level implementation if it won't work in the current code base.
Also, what does everyone think about the idea of some sort of "replace" attribute for the module? How should it get set? "import module; module.replace=1". I'm probably showing a little lack of knowledge here. Teach me and I'll get it.
____________________________________________________________________________________
Pinpoint customers who are looking for what you sell.
http://searchmarketing.yahoo.com/
[View Less]
Greg Ewin wrote:
> What you suggest sounds like it ought to be possible,
> at first sight, since Python function objects are already
> containers with a reference to another object that
> holds the function's code.
> The problem will be figuring out *when* you're redefining
> a function, because the process of loading a module is a
> very dynamic one in Python. Defining functions and classes
> is done by executing code, not by statically analysing
> declarations as a …
[View More]C compiler does.
My implementation is definitely a high level scetch.
Greg,
The kind of issues you are bringing up is exactly the kind of thing I'm looking for. If there are more, lets see them.
Would temporarily marking the module with "replace" work? I would think that when the function is defined, it has access to the module (because it is adding to its dictionary) and it could check for the "replace" attribute. I'm assuming a certain sequence of execution here since the "replace" attribute would have to removed after the function/method code was executed/loaded. Anyone who knows that this isn't the case, please shoot this down.
Another post I read proposed a Reclass feature that only worked for classes. Given the macro language scenario, you definitely need functions too.
____________________________________________________________________________________
Tonight's top picks. What will you watch tonight? Preview the hottest shows on Yahoo! TV.
http://tv.yahoo.com/
[View Less]