Jump to content

pyscripter

Members
  • Content Count

    920
  • Joined

  • Last visited

  • Days Won

    56

Everything posted by pyscripter

  1. pyscripter

    Delphi4PythonExporter

    Please submit an issue to the relevant repo. I would expect that simply recompiling the component source with Delphi 12 should work.
  2. pyscripter

    TDirect2dCanvas Issues

    The Direct2D way of printing is to use the ID2D1PrintControl interface (Printing and command lists - Win32 apps | Microsoft Learn). You can look at SynEdit/Source/SynEditPrint.pas at master · pyscripter/SynEdit (github.com) for how this works.
  3. Features missing in the Delphi editor: Proper Unicode handling . It does not even support combining characters. Multi-cursor/selection editing Modification (track changes) bar that works with undo. Accessibility support Drag & drop editing triple and quadruple click support double/triple click and drag support Enhanced scroll bar as in VS Code ...
  4. pyscripter

    2D numpy Array back to delphi

    See The buffer protocol has been implemented · pyscripter/python4delphi · Discussion #443 (github.com) and demo 35.
  5. pyscripter

    Locking an Object

    Here is a lock-free implementation for your FHIROperationFactory function. var SingletonFHIROperationFactory : IFHIROperationFactory function FHIROperationFactory: IFHIROperationFactory; var LFHIROperationFactory: IFHIROperationFactory; begin if SingletonFHIROperationFactory = nil then begin LFHIROperationFactory := TFHIROperationFactory.Create; if InterlockedCompareExchangePointer(Pointer(SingletonFHIROperationFactory), Pointer(LFHIROperationFactory), nil) = nil then SingletonFHIROperationFactory._AddRef; end; Result := SingletonFHIROperationFactory; end; Delphi does something similar in some places.
  6. pyscripter

    Locking an Object

    Indeed. This is the whole purpose of locking.
  7. pyscripter

    DelphiVCL and asyncio

    The Embarcadero fork of P4D, is often ahead of the PyScripter repo, but it is currently behind. Its main focus is the generation of the delphivcl and delphifmx extension modules as well as Android support. The two repos are synced regularly. I am only responsible for the pyscripter P4D home repo. In most cases it does not matter which one you use.
  8. pyscripter

    DelphiVCL and asyncio

    Not too bad an idea. For instance this appears to run OK. import threading import time from delphivcl import * class DesktopView(Form): def __init__(self, owner): self.SetProps(Caption = "Welcome") # create and set update timer self.tmrUpdate = Timer(self) self.tmrUpdate.Enabled = False self.tmrUpdate.Interval = 1 self.tmrUpdate.OnTimer = self.__on_timer_update self.tmrUpdate.Enabled = True def __on_timer_update(self, sender): time.sleep(1) def app_main(): # initializes GUI Application Application.Initialize() Application.Title = "OPC UA Client Demo" # creates main application form app = DesktopView(Application) app.Show() FreeConsole() # enters in vcl main loop Application.Run() Application.Free() def inthread(): for i in range(20): print(i) time.sleep(1) if __name__ == "__main__": threading.Thread(target=inthread).start() threading.Thread(target=app_main).start() You could run the asyncio in a thread as in python - Running asyncio loop and tkinter gui - Stack Overflow. Also please submit an issue to the delphivcl project to expose the Application.OnIdle event. That would make the use of timer unnecessary.
  9. pyscripter

    Delphi 12 is available

    Like most new features and bug fixes, this introduces new bugs: https://quality.embarcadero.com/browse/RSP-43261 https://quality.embarcadero.com/browse/RSP-43263 Update I found a third even more serious issue related to the changes introduced for font scaling: https://quality.embarcadero.com/browse/RSP-43270
  10. pyscripter

    Delphi 12 is available

    The problem is that if you maintain open source components that support many versions of Delphi, this does not eliminate anything. It just adds another IFDEF in the code. Having said that, it is good to see it fixed.
  11. pyscripter

    Delphi 12 is available

    @Uwe RaabeUnfortunately though, your [RSP-35301] Option to design in Screen PPI but save in 96 PPI - Embarcadero Technologies is not, despite the many votes it got. And by the way thanks for your article. Highly recommended. Three of my reported issues were fixed and one more is wrongly marked as fixed (https://quality.embarcadero.com/browse/RSP-31137). But I have to agree with @David Heffernan that the list of new features is rather underwhelming, if you are not using C++ Builder. David what do you think of the change related to floating point exceptions?
  12. There have been a large number of new features and enhancements implemented in the P4D library recently . This discussion document provides an overview of these developments.
  13. In case you have not heard, Python 12 made a breakthrough towards running threads in parallel. For now, the feature is only available through the C-API and there are limitations. But still, the performance boost that comes from the exploitation of multiple cores makes this feature very desirable. P4D makes this feature very easily accessible by adding a new execution mode to TPythonThread. There is also a new demo (Demo 36) that shows how to run threads in parallel. If you are wondering about the performance boost, see the results below: Classic Subinterpreters: prime count 78498 prime count 78498 prime count 78498 prime count 78498 prime count 78498 Elapsed ms: 13695 Subinterpreters with own GIL: prime count 78498 prime count 78498 prime count 78498 prime count 78498 prime count 78498 Elapsed ms: 3482 You can find more details in this P4D announcement.
  14. pyscripter

    True thread parallelism with P4D and Python 12

    Let's not start language wars in this thread, which is about a significant development in Python 12 and how take advantage of it using P4D. P4D is about combining the strengths of python and Delphi, not choosing one versus the other.
  15. pyscripter

    Running python code in Delphi threads

    Python 3 was released in 2008. I would read something more recent that is based on Python 3. pamoroso/free-python-books: Python books free to read online or download (github.com)
  16. 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.
  17. @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.
  18. 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?
  19. pyscripter

    Memory leak with anonymous methods.

    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.
  20. pyscripter

    Memory leak with anonymous methods.

    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).
  21. Importing a module for second, third.. time has no significant performance cost.
  22. For answers see: python4delphi/Tutorials/Webinar II at master · pyscripter/python4delphi (github.com) python4delphi/Tutorials/Webinar II/VarPythDemo at master · pyscripter/python4delphi (github.com)
  23. 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!
  24. @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?
  25. 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.
×