Wish: Python print("string") not to be displayed in realtime

Sometimes I want a lot of text printed (or often I forget to disable print… when testing on larger data sets) and Rhino prints one line of text per display update frame. Causing it to be limited to 60 frames per second on most computers. Could this be done in the background so we don’t need to see every printed text string?

I also see that rs.Prompt() is much faster than the print command, so I guess it would need to be a buffer of some sort that stores the data.

For all of us who code as simple as possible I think this could be a nice feature.

(And I understand that I can store all the strings in a list and present them at will, but when prototyping I like using print every now and then)

@dale I guess this is for you :slight_smile:

1 Like

Hi @Holo,

Printing to Rhino’s command line is independent of how viewports are rendered.

Perhaps I don’t understand the problem you are trying to solve. Is there someway for us to repeat what you’re seeing?

Thanks,

– Dale

Here are the results with different settings:

740 calculations done in 1 second with Print
1180 calculations done in 1 second with Prompt
1066431 calculations done in 1 second with None

import rhinoscriptsyntax as rs
import math
import random
import time

def print_prompt_test(value):
    startTime = time.time()
    n = 1
    list = []
    while True:
        # do something and track number of calculations
        result = math.cos(random.random())
        n+=1
        list.append(result)
        if value == "Prompt":
            rs.Prompt (str(n))
            if time.time()-startTime >1:
                print (str(n)+" calculations done in 1 second with "+str(value))
                break
        elif value == "Print":
            print (str(n))
            if time.time()-startTime >1:
                print (str(n)+" calculations done in 1 second with "+str(value))
                break
        else:
            if time.time()-startTime >1:
                print (str(n)+" calculations done in 1 second with "+str(value))
                break

print_prompt_test("Print")
print_prompt_test("Prompt")
print_prompt_test("None")

Today I was prototyping a mesh drape function and used print to see if a vertex projection got a reslut or not, and all was dandy until I tested on a large mesh (90.000 vertices) and had to wait many minutes for it to complete. (Yeah, I should have saved first so I could have killed Rhino, but I hadn’t… my bad :wink: )

So when things are 900x slower something that takes 1 seconds to compute suddenly takes 15 minutes. A lesson learned many times before and will be learned again for sure, but that’s life :slight_smile: Thus the wish, I figure if I am dumb then others might be as well.

I don’t know if it is possible to do anything about it, or worth spending time on, but it would be nice.
And of course nobody would like 90.000 printouts to the command history, that doesn’t make sense at all. So it’s more of a safety thing I guess.

Hi @Holo,

There is significant code behind both print and prompt. So I can understand the delays. However, when a dev wants to print or change the prompt, they expect it to happen immediately. I don’t see anything to do here.

– Dale

Thanks for the input, I see your point and agree. If anything it should be an option like pressing F12 to disable printing while running or something, but that would just mess up other key mappings. So yeah, I guess something has to be learned the hard way… it builds better programmers :wink:

Totally OT:
I just ran my actual script on V8 and it completed it in 0.8 seconds, while v7 uses 1.3… that’s awsome!
60% speed gain is great.

(I am making some road tools that also can affect a terrain: Still wip though)



And the geometry is updateable so I can change the roads and and the terrain will update too.
Not with history, so you have to pick it and run the command again, but it will know that it should update instead of asking for the input again.

Hi Holo,

Would writing print = rs.Prompt (without braces) at the top of all your scripts help?

1 Like

Thanks, nice creative idea!
I guess if we made it like a definition that takes runtime into the equation and if enough time has passed since last print then print (or prompt, I do that on a lot of scripts to show % processed today, but I have never though of replacing print with a definition or alias. And I guess that + silently pass all the other data to the command history is what I basically wished for.

But it would require me to add that definition to every script, so I guess I’m back to ground zero :slight_smile: Better to remember how rhino works for now.

(But on the other hand you have now gotten me thinking so I’ll let my subconscious work on it for a while!)

By the way I wish that ESC was hard wired into python too, so if pressed then cancel (unless programmed not to) instead of having us program to do something IF pressed. Because that would solve it too.

The main point in my wishes here is making it easier to prototype quickly scripts with out having to think of all issues we can run into along the way. (But I see it can be counter productive when moving out of the prototyping face)

1 Like