-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
print is println? #2142
Comments
Indeed. The The core libraries don't have a function that doesn't add a new-line character, but the It's a bit more complicated but here are roughly the steps to get it. Install the package. If you don't have any package installed yet follow these steps: jag pkg init # In your project root.
jag pkg install host To write to stdout: import host.pipe
import writer show Writer
main:
writer := Writer pipe.stdout
writer.write "foo" Note that |
Actually, I just saw that we have a private function that does a main:
write-on-stdout_ "foo" false // The 'false' avoids the newline. Given the trailing '_' it's private and therefore subject to change, but if you just want to run a few tests it might be easier than to install the |
Thanks, that allowed me to hit the next problem :-)
Trying to write binary, a byte rather than a char (just mandelbrot in pbm format, nothing of any importance). Maybe something I should come back to in a few weeks, after the IO library work. |
I would use PNG instead of PPM, but the following could be adapted to PPM if that's what you want. Once you have stdout from host.pipe you can use the write method which takes binary data and does not append a newline. You need to install the host and png-tools packages:
Use
Instead of importing host.pipe and using pipe.stdout you could use:
|
Thanks. I discovered that the most foolish approach gives the expected output:
Next byte-acc as a row buffer or I'll look at Writer. Thanks again. |
Not sure it is relevant in your case, but fyi: you can create byte-arrays with The writer is really simple: to-write := data.size
// As long as the whole data wasn't written try again.
while written < to-write:
written += out.write data[written..] |
I've copied a few tiny programs line-by-line from C and Java and Python into Toit. Very much C written in Toit. Java written in Toit. Python written in Toit. The programs have nothing to do with micro controllers. Nothing to do with the use you intend for Toit. I've timed those tiny tiny programs and would probably publish the program source and times, alongside programs and times for other programming languages. This is always kind-of foolish. With Toit it feels more foolish. The programs are being run on a desktop machine not ESP32. The comparison is with CPython not MicroPython, Java SE not Java ME, Go not TinyGo. So Toit programs will be presented as slower than everything except ruby-1.8.7 — and I'm not hopeful that people will do more than take that at face value. Best-case it's irrelevant, no one will notice :-) Is it too much like a misrepresentation? |
If you send us the programs we can have a look and make them a bit more "toity" and avoid the worst pitfalls. Obviously, it won't be able to compete with a VM that has a good JIT (like Java, or JavaScript), but IIRC we were faster than Python on typical benchmarks (deltablue, richards, ...). |
simple.toit is line-by-line to match these simplistic implementations. Takes ~53 minutes, output redirected to /dev/null. After removing the Others simple-programs.zip Command line is shown last in simple-toit-1.html |
Thanks. |
Various ways which seem to give similar times for the toit programs.
Like this for the first measurement which has stdout checked against an expected value
|
I've speeded up floating point operations. This will be in the next release. |
I look forward to seeing how that works out. |
Jaguar v1.31.0 and Toit SDK version v2.0.0-alpha.143 are released now with the improved performance. |
I see
and then
With these alpha versions are the compile line options like |
The |
Looked a bit more: the |
Whatever the max performance / lowest memory use options might be. |
github doesn't seem to allow html attachments, so: python3-toit.zip
|
Seems like host print is actually println, is there something without the /n ?
The text was updated successfully, but these errors were encountered: