Jump to content

Cristian Peța

Members
  • Content Count

    438
  • Joined

  • Last visited

  • Days Won

    5

Posts posted by Cristian Peța


  1. 1 hour ago, Ian Branch said:

    There is only the one form.

    If you create only one form and want to keep it to change the table the I ask myself as Remy asked: why is that code in the constructor?

    Also calling Abort into the constructor will destroy the form.


  2. 5 hours ago, JonRobertson said:

    Disassembled code would reveal the code generated by the compiler. But it isn't going to reveal the contents of memory (registers, stack, or heap) prior to the code even executing. As Dalija points out, I could execute it once and the memory was zero at the time and execute it a thousand more times and the memory has values aside from zero.

    Compiler generated code can tell you if a variable is automatically initialized or not. I only wanted to point out that there is a method to check if an AI statement in this regard is true or not.

    • Like 1

  3. 1 hour ago, Dalija Prasnikar said:

    For instance AI can say "Local variables are automatically initialized" and "Local variables are not automatically initialized" If you don't know which of those statements is true, you will not be in position to verify. You cannot even check with code, because local variable can accidentally occupy memory that was zero at the time, so it may seem like the first statement is true, while it is not. 

    Assembler of that code will show the truth... but I think that someone that ask such things do not have ability to read assembler.


  4. 4 minutes ago, bravesofts said:

    Do random values only occur for local variables?

    Not. The best practice is to initialize to nil if you need this.

    7 minutes ago, bravesofts said:

    Why does uninitialized memory sometimes contain garbage values, especially when an object hasn't been allocated yet? 

    Because there was something before and that memory was deallocated.

    It doesn't have anything with object allocation. You can allocate the memory for an object and you variable will remain as it was.

    var 
      LObj: TObject;
    begin
      TMyClass.Create;
      //LObj is not changed and will contain garbage

     

    10 minutes ago, bravesofts said:

    LObj is just a variable that will reference the object once TMyClass creates it.

    Only if you pass the value of the object to the variable:

    LObj := TMyClass.Create;

     

    13 minutes ago, bravesofts said:

    Does TMyClass automatically assign anything to LObj just by declaring it like this? 

    
    var
      LObj: TMyClass;

      

    Not. Declaration will only allocate the memory for the variable (a typed pointer in this case) and that memory will contain garbage.

    • Like 1

  5. 8 hours ago, Celebr0 said:

    I just can't run 10 instances of a .py script through Python4Delphi, right?

    You can run 10 instances with Python4Delphi but you have GIL limitation because Python. Python limits you, not Python4Delphi. Is there a library in this word that can circumvent GIL? 

    You can use CreateProcess and run 10 processes. You don't need Python4Delphi for this. But in the same processes you are limited by GIL. And all this because Python, not Python4Delphi.

    Is Python a bad and low quality implementation of the language because this?


  6. When you start 10 console windows you are starting 10 processes.

    With Python4Delphi you will start all 10 in the same process. In this way you are limited by GIL.

    You can start from a Delphi app 10 process executing same Python script but not using Python4Delphi.

    Python4Delphi runs in your process and so you have a lot of advantages but also GIL.

     

    PS. You can start at the same time 10 Delphi app and you will have 10 Python scripts running from Python4Delphi at the same time without GIL limitation.


  7. 1 hour ago, Andro12 said:

    Data processing: Thousands of records are handled by the application in datasets. I'm currently manipulating data in-memory using TClientDataSet. Large dataset activities like sorting and filtering are taking longer than expected for me.

    TClientDataSet is pretty fast. Faster than FireDAC.

    You should reduce filtering and sorting if this is a bottleneck. Consider using CloneCursor if you need same sorting or filtering many times.

     

    But first: use a profiler!

     

    • Like 1

  8. Strange how it worked in D7. Maybe the garbage on the stack was useful.

    With stdcall TSystemTime will be passed as value directly on the stack.

    Without stdcall TSystemTime will be passed as reference.

    Do I'm missing something?

     

    https://docwiki.embarcadero.com/RADStudio/Sydney/en/Program_Control_(Delphi)

    Quote
    • Sets, records, and static arrays of 1, 2, or 4 bytes are passed as 8-bit, 16-bit, and 32bit values. Larger sets, records, and static arrays are passed as 32-bit pointers to the value. An exception to this rule is that records are always passed directly on the stack under the cdecl, stdcall, and safecall conventions; the size of a record passed this way is rounded upward to the nearest double-word boundary.

     

×