-
Content Count
778 -
Joined
-
Last visited
-
Days Won
41
Everything posted by pyscripter
-
using python4delphi to call python function and get return result
pyscripter replied to mbaghb's topic in Python4Delphi
I have no idea why and how you are building a DLL, but from the size I can tell that you are pulling in a large chank of the Delphi RTL. Not except the source code. -
Memory exception fault when using PyArg_ParseTuple(y*) with buffer pointer
pyscripter replied to dnbif72's topic in Python4Delphi
@dnbif72 Support for the buffer protocol was added to P4D. A new demo (Demo35) shows how to access (read and write) numpy arrays super fast using the buffer protocol.- 5 replies
-
- parsetuple
- exception
-
(and 2 more)
Tagged with:
-
This is a simplified version of what I had in my app. procedure Test(); var TerminateProc: TThreadProcedure; S: string; begin S := 'Terminated'; TerminateProc := procedure begin ShowMessage(S); end; TThread.CreateAnonymousThread( procedure begin // Do stuff TThread.Queue(nil, TerminateProc); TerminateProc := nil; // Memory leak without this end).Start; end; I had to insert the statement with the comment "Memory leak without this" to avoid memory leaks. Any idea why the compiler does not free TerminateProc on its own? Is this a compiler bug?
- 4 replies
-
- anonymousmethods
- threads
-
(and 1 more)
Tagged with:
-
Memory leak with anonymous methods.
pyscripter replied to pyscripter's topic in RTL and Delphi Object Pascal
You are right. I have removed the code from the post, so as not to confuse people. The code at the first post works well.- 4 replies
-
- anonymousmethods
- threads
-
(and 1 more)
Tagged with:
-
Memory leak with anonymous methods.
pyscripter replied to pyscripter's topic in RTL and Delphi Object Pascal
Answer myself. I remember having seen these some time ago, when I have been bitten by this again: delphi - Memory leaks happens in nested anonymous method - Stack Overflow TURBU Tech » Blog Archive » How to leak a class you never defined (turbu-rpg.com) (see Barry Kelly's comment).- 4 replies
-
- anonymousmethods
- threads
-
(and 1 more)
Tagged with:
-
using python4delphi to call python function and get return result
pyscripter replied to mbaghb's topic in Python4Delphi
Importing a module for second, third.. time has no significant performance cost. -
using python4delphi to call python function and get return result
pyscripter replied to mbaghb's topic in Python4Delphi
For answers see: python4delphi/Tutorials/Webinar II at master · pyscripter/python4delphi (github.com) python4delphi/Tutorials/Webinar II/VarPythDemo at master · pyscripter/python4delphi (github.com) -
Memory exception fault when using PyArg_ParseTuple(y*) with buffer pointer
pyscripter replied to dnbif72's topic in Python4Delphi
Your code leads to memory corruption. PyArg_ParseTuple(args,"y*",&data); will copy the Py_Buffer structure to the address of data overwriting whatever was after that. If you wait for a few days, I will add the Py_Buffer stuff to P4D and provide an example of getting raw access to nympy.ndarray data. Looking forward to receiving C++ Builder installation instructions!- 5 replies
-
- parsetuple
- exception
-
(and 2 more)
Tagged with:
-
Memory exception fault when using PyArg_ParseTuple(y*) with buffer pointer
pyscripter replied to dnbif72's topic in Python4Delphi
@dnbif72By the way, since I am not using C++ Builder, I am looking for someone to provide detailed instructions for installing P4D in C++ Builder. The instructions provide David Intersimone are outdated. See for example: No Python_D.dproj project file inside python4delphi-master\Packages\Delphi\Delphi 10.4+. · Issue #416 · pyscripter/python4delphi (github.com) Could you please help?- 5 replies
-
- parsetuple
- exception
-
(and 2 more)
Tagged with:
-
Memory exception fault when using PyArg_ParseTuple(y*) with buffer pointer
pyscripter replied to dnbif72's topic in Python4Delphi
What do you expect to be passed to data? Please see the docs: Parsing arguments and building values — Python 3.12.0 documentation "y*" is one of the most esoteric formats. This is the correct way of using it by Victor Stinner one of the python gurus (from this web page). static PyObject * getargs_y_star(PyObject *self, PyObject *args) { Py_buffer buffer; PyObject *bytes; if (!PyArg_ParseTuple(args, "y*", &buffer)) return NULL; bytes = PyBytes_FromStringAndSize(buffer.buf, buffer.len); PyBuffer_Release(&buffer); return bytes; } Note that the Py_buffer structure and related functions are not yet defined in P4D, so you will have to get it from the python headers.- 5 replies
-
- parsetuple
- exception
-
(and 2 more)
Tagged with:
-
Did you install the master branch from pyscripter/python4delphi: Free components that wrap up Python into Delphi and Lazarus (FPC) (github.com)? Here Demo01 and other demos run fine.
-
You may want to give pyscripter/Ssh-Pascal: Delphi ssh library wrapping libssh2 (github.com) a try. It is a wrapper around libssh2, includes scp, sftp, ssh support. Very fast.
-
Use TThread.ForceQueue from inside the OnShow handler. TThread.ForceQueue accepts an optional delay.
-
Question: Is there a way to tell whether a method is overloaded using rtti?
pyscripter posted a topic in RTL and Delphi Object Pascal
As per title. For instance: A) Second method hides the first ClassA = class procedure Test(I: Integer); end; ClassB = class(classA) procedure Test(S: string); end; B) Second method overloads the first ClassA = class procedure Test(I: Integer); overload; end; ClassB = class(classA) procedure Test(S: string); overload; end; How can you tell the difference with Rtti. GetMethods would show both methods in a similar way. -
Rtti Question: Is there a way to tell apart class fields from other fields?
pyscripter posted a topic in RTL and Delphi Object Pascal
TTest = class A: string; class var B: string; end; Is it possible to tell that B is a class field using Rtti? Ditto for properties. And if you get a chance have a look at my other Rtti question. -
Rtti Question: Is there a way to tell apart class fields from other fields?
pyscripter replied to pyscripter's topic in RTL and Delphi Object Pascal
Never mind. I forgot the answer to an older question. No rtti is generated for class fields and properties, which is a shame. It does for class methods though. -
Question: Is there a way to tell whether a method is overloaded using rtti?
pyscripter replied to pyscripter's topic in RTL and Delphi Object Pascal
But so do overwritten methods, virtual methods etc. -
This was a python reference counting issue. Fixed in version control. Please try the latest version and confirm the issue is solved.
-
Are you following the instructions at Installation · pyscripter/python4delphi Wiki (github.com)? Specifically, did you build all packages before installing them?
-
Clear the output?
-
Playing with Windows Fibers by emulating Python Generators
pyscripter replied to darnocian's topic in I made this
This project deserves some attention (greenlets-coroutines, generators, channels and more). It is based on fibers. -
Unable to run 2 TPythonEngine per VCL application
pyscripter replied to Dmitry72's topic in Python4Delphi
You cannot load multiple versions of any dll simultaneously in a single process. If you study Demo 33, you will see that this is not necessarily the case. -
Unable to run 2 TPythonEngine per VCL application
pyscripter replied to Dmitry72's topic in Python4Delphi
Why do you conclude that? If you want to run python code in threads, please study Demo 33 and search for related content in this forum (there is lots). Also google for "Global Interpreter Lock". -
In my Delphi apps, I use the dated CHM Html Help format to provide user help. When help is invoked from the Delphi app using the Application help commands, Ctrl+F to search within a help page does not work. However, if open the same chm file outside the Delphi app, Ctrl+F works fine. Any clues as to what causes this issue? Note: The Delphi app is compiled with Alexandria (v11) and I am testing on Windows 11.
-
Module "sentence_transformers" import in P4D not possible
pyscripter replied to JGMS's topic in Python4Delphi
Running python in threads is not straightforward. Have a look at TPythonThread, Demo 33, and search this forum for relevant discussions.