Sunday, February 9, 2025

PyScripter v5.2.1 released

PyScripter v5.2.1 is now available at Sourceforge.  This release brings a number of significant improvements in the areas of LLM-Assisted coding and Debugging.   This is the list of the main new features and fixes:

  • New Features:
    • LLM Support improvements
      • Added support for DeepSeek LLM
      • Added support for DeepSeek and OpenAI "o" LLM reasoning models
      • Improved display of LLM output
      • Syntax Highligting for 300 languges
      • Exposed the temperature LLM parameter
      • Printing of LLM output
    • Debugging
    • Surround editor selection with brackets and quotes
    • Added two new styles: Windows11 MineShaft (new default) and Windows 11 Impressive Light
  • Issues addressed:

DeepSeek and Other improvements to LLM-Assisted Coding

 The forthcoming version of PyScripter has a number of improvements to LLL-assisted coding:

 When it comes to coding, DeepSeek is simply amazing.  It is now supported both in the Chat and Assistant.

  • The rendering of the LLM responses is much improved and it is now on a par with the Web interface of the LLM providers.

Code is presented in code boxes, and using the icons in the header, you can copy the code into the clipboard or directly into a new editor.

Markdown is now rendered perfectly:


  • Support for DeepSeek and OpenAI LLM reasoning models

You can now follow the reasoning behind the answers, using DeepSeek's deepseek-reasoner model or OpenAI's "o" models, such o1-mini.  The reasoning is presented without cluttering the output.


 

  • Other improvements  

  • The temperature LLM model parameter is exposed by the Chat UI.   It is a decimal number between 0 and 2 that controls the randomness of the results (higher values leed to more random answers).
  • You can now print the chat topic content. 
  • Syntax highlighting for about 300 programming languages is available.  So you can now ask questions not just about python but also for other languages.

 And don't forget the Assistant.  While coding Assistant completion is available by pressing Ctrl+Alt+Space. as well as by using the editor context menu.


Thursday, January 30, 2025

Breakpoint conditions and ignore counts

 PyScripter has always supported conditional breakpoints.   Conditional breakpoints allow you to finetune the debugging experience, by only stopping execution when certain conditions are met.

Consider the following example:

def main():
    sum = 0
    for i in range(1000):
        sum = sum + i
    print(sum)

if __name__ == '__main__':
    main()

Say you are interested to know when sum becomes >= 1000.  If you set a breakpoint at the 4th line of the code, it will be tedious and time consuming to reach that point.   What you can do is to set a conditional breakpoint:


When you debug the code, execution will stop at the break point only when the condition is met (i = 46).

As you can tell from the screenshot above, the forthcoming version of PyScripter, introduces and new breakpoint property "Ignore Count".  If you set the the Ignore Count to a positive integer value, then the breakpoint will be ignored a number of times equal to that value.  So in the above example if you remove the condition and set the Ignore Count to 100, execution will stop when i becomes 100.  When you resume execution, the breakpoint will be ignored another 100 times.

There are a few ways to set the breakpoint properties Condition and Ignore Count.

  • In the Breakpoints Window select the property you want to change and press F2.  This will allow you to edit the property directly.  Press Enter when you are done:


  • In the Breakpoints Window right-click on the breakpoint and select "Breakpoint Properties...".  A dialog box like the following pops up and you can edit the values.



  • In the editor, when you click on a breakpoint you get a context menu (new feature) from which you can select "Breakpoint Properties..."


Another breakpoint tip:

  • You can quickly disable/enable a breakpoint by Ctrl + clicking on it in the editor gutter.


Saturday, January 18, 2025

Teaser: Super fast debugging is coming to PyScripter

 You expect code to run with debugging much slower than without.  Indeed this is the case and with python, debugging can be sometimes painfully slow.  

A relatively recent, low-level feature that was introduces in Python 3.12 is monitoring. Monitoring allows programmers to hook into low level events that occur during the execution of code.   This is similar to tracing, which is used by debuggers, but with much greater granularity and control.  It turns out that monitoring can help make faster debuggers.  Much faster.  The next version of PyScripter will include a new debugger that is based on monitoring for python versions 3.12+.  Just to give you a taste of the speed-up you get, consider the following code:

import time

def test():
    start_time = time.time()
    for i in range(1000):
        for j in range(1000):
            j + i
    cost = time.time() - start_time
    print("Elapsed time: ", cost)
    f(0)

def f(x):
    # Set breakpoint here
    x *= 2
    return x + 1

test()

If you set a break point at the line "f(0)" and start debugging, this is what you get with the PyScripter v5.1.4 and python 3.13. 

*** Remote Interpreter Reinitialized ***
Elapsed time:  2.5882363319396973
[Dbg]>>> 

There are a million iterations that happen before you reach the breakpoint, so this takes about 2.5 seconds. If you do the same with the forthcoming release of PyScripter you get:

*** Remote Interpreter Reinitialized ***
Elapsed time:  0.016160964965820312
[Dbg]>>> 

This is more than x150 speed-up.  The code until you reach the breakpoint, runs almost as fast as without debugging.  The new debugger shines when you debug over loops or other pieces of code that it is executed repetitively.  For other types of code the speedup is not as impressive.

The new release also back-ports some debugging improvements introduced in python 3.14 to python versions 3.10+.   So users of these versions will experience faster debugging.

Tuesday, January 7, 2025

PyScripter v5.1.3 released

PyScripter v5.1.3 is now available at Sourceforge. Despite being a minor release it does include a number of new features and improvements:

  • Support for Python 3.14
  • Support for free-threaded python
  • New external tool "Create venv"
  • Support tqdm and similar modules in the interactive interpreter (#812)
  • The Chat Window renders Markdown
  • The Assistant can use a greater variety of Ollama models
  • Layouts now include the secondary workspace status (#494)

Friday, December 13, 2024

Create virtual environments the easy way

A powerful and possibly underused feature or PyScripter is the Externa Tools.  A collection of such tools is included with the installation, but you can create your own.

Virtual python environments are isolated workspaces, that allow you to install packages and test code, without messing up the main python installation.  After using them for a specific purpose you can just delete them.  Python ships with a module called venv, that allows you to easily create such virtual environments.

Instead of creating such environments from the command prompt you can create an external tool to do that.  You can can create new external tools using Tools, Configure Tools, Add.  You can then fill the information as in the image below.


You can run the created tool by selecting it from the Tools, Tools menu.  It will prompt you for a folder in which the virtual environment will be created and then will create the environment.  To use the created environment, you then go to Run, Python Versions, Setup Python Versions..., add a new unregistered python version at the new virtual environment folder and activate it.

If you are using Conda python distributions you can create an external tool to create conda virtual environments instead.  Note though, that conda virtual environments are much more heavyweight than the venv ones.

The next release of PyScripter will add such an external tool to new installations and you can easily add it to existing installations.

Thursday, December 12, 2024

Free-threaded python support is coming to PyScripter

One of the main limitations of Python has been its inability to make use of the multiple cores of modern CPUs, at least not easily. This is due to the infamous Global Interpreter Lock.  In essence, due to the presence of the GIL, only one python thread can execute at a time,

Python 3.13 has changed this and provides an experimental free-threaded (or No-GIL) version.  It is included in the standard installer, but you need to select the relevant option (see below) to install it.

Python 3.13 Windows Installer

What you get is a another python executable called python3.13t.exe alongside python.exe.   This executable runs the free-threaded version of python.

This RealPython article provides an in-depth coverage of free-threaded python and is recommended reading. .

The next version of PyScripter will include support for free-treaded Python. The Run, Python Engine submenu now includes an option to use the Free-Threaded version if is available.  It also allows you to easily switch between the standard and free-threaded version.


To get an idea of the performance benefits from using free-threaded python, here are the the results of running the benchmark code of the RealPython article without/with free-threading:

*** Python 3.13.0 (tags/v3.13.0:60403a5, Oct  7 2024, 09:38:07) [MSC v.1941 64 bit (AMD64)] on win32. ***
>>> =======================================================================
💻 Windows 64bit with 20x CPU cores (Intel64 Family 6 Model 151 Stepping 2, GenuineIntel Little Endian)
🐍 CPython 3.13.0 C:\Python\Python313\python.exe
Free Threading: unsupported
=======================================================================
Running 20 threads...: 15.07s


*** Python 3.13.0 experimental free-threading build (tags/v3.13.0*** Remote Interpreter Reinitialized ***
=======================================================================
💻 Windows 64bit with 20x CPU cores (Intel64 Family 6 Model 151 Stepping 2, GenuineIntel Little Endian)
🐍 CPython 3.13.0 C:\Python\Python313\python3.13t.exe
Free Threading: enabled ✨
========================================================================
Running 20 threads...: 2.81s