Python for Delphi problem
Greg Chapman
glc at well.com
Wed Feb 12 10:53:42 EST 2003
More information about the Python-list mailing list
Wed Feb 12 10:53:42 EST 2003
- Previous message (by thread): performance question
- Next message (by thread): Python for Delphi problem
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, 12 Feb 2003 00:21:52 GMT, Kyle Yancey <kyle at lakeofburningfire.org> wrote: >Thanks, that's much nicer. I was explicitly copying the string, >because I kept getting an error saying that I was writing to some >memory location. Since the PyString_AsString function returned a >pointer to the internal buffer, I thought that that might be the >problem. I think I've found the real problem though. I was DECREFing >the pyItem returned from pyList. PyList_GetItem returns a borrowed >reference not a new one, so it shouldn't be DECREFed. This code gives >no EAccessViolations and works perfectly. Thanks for all your help. > Well, you're right -- I should have been more careful about refcounts (sorry about that). Partly so I wouldn't have to worry about the refcounting rules in all my client code, I actually wrote my own interface between Delphi 5 and python which uses Delphi interfaced objects to hold the python objects. It's not as fast as the PythonforDelphi code, since every Python object has to be wrapped by a Delphi object, but it makes for nicer looking code: procedure GetModKeys(const Interp: IPyInterpreter; const Modname: string; Dest: TStrings); var Keysiter: IPyIterator; begin Keysiter:= Interp.ImportModule(Modname).GetAttr('__dict__').GetIterator; Keysiter.AsStrings(Dest, false); end; --- Greg Chapman
- Previous message (by thread): performance question
- Next message (by thread): Python for Delphi problem
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list