Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
major improvements to numeric python object conversion to tcl
When creating a new Tcl object from a Python object, and the Python object was numeric, 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. Tohil, now, if the python object is a number, tries PyLong_AsLongAndOverflow to convert to long and if it works without overflow, returns a Tcl_NewLongObj. If it overflowed, tohil tries PyLong_AsLongLongAndOverflow, and if that doesn't overflow, tohil returns a new wide integer through Tcl_NewWideIntObj. Likewise if the number is floating point, it is converted through 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 Tcl.
- Loading branch information