Tohil tclobj integer math always at 64 bits; Faster Python-to-Tcl numeric conversions; TclProcs now return tclobj by default #75
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
call
defaults totclobj
#72)When creating a new Tcl object from a numeric Python object, previously tohil always converted it to a string, which thereby supported both Tcl and Python's arbitrary precision arithmetic, but would be slower than using access functions that worked on machine-native numeric types when those types were large enough to handle the numbers being represented.
Tohil, now, if the Python object is an integer, tries PyLong_AsLongAndOverflow to obtain it as a C long, and if it works without overflow, uses Tcl_NewLongObj to create the Tcl equivalent. If it overflowed, indicating the number is too large for a long, Tohil tries PyLong_AsLongLongAndOverflow, and if that doesn't overflow, tohil creates and returns a new wide Tcl integer through Tcl_NewWideIntObj.
Likewise if the Python object being converted is floating point, it is brought into Tcl using PyFloat_AsDouble and Tcl_NewDoubleObj.
Now, only if the number is wider than a long long, or complex, is it converted to a string for use by Tcl.