Closed myusernameisunique closed 8 months ago
Alright, that was a convoluted one, but things should now be way more consistent and the example above works, except that both val
and values
now return LowLevelView
s. This for consistency, although I realize that that's not the old behavior. The reason for keeping them LowLevelView
s, is that there's no reason to assume that a char[]
array is in fact a null-terminated string, but moreover, by copying into a Python str
, any elements beyond a possible '\0'
become inaccessible (and can't, for example, be assigned to), the sub-array itself can't be passed back to C++ via a pointer, etc.
To make conversion to C strings easier, I added an as_string()
method (works only for 1-dim char arrays) and 1-dim slicing.
Released with release 3.1.0. Feel free to reopen if you still have issues.
Great! I will try out version 3.1.0 this week hopefully. It makes sense to me that both val
and values
should return LowLevelViews
. I will re-open if I find anything else. Thank you!
It seems like the behavior of char arrays (char[], char, char[][], char[]) has changed in version 3.0.0 as compared to version 2.4.2. Here is the code to reproduce:
Here is the result from version 2.4.2 (this one successfully prints the pointers):
Here is the result from version 3.0.0 (version 1 of 2 completes without error, but prints garbage for pointers):
Here is the result from version 3.0.0 (version 2 of 2 fails with OverflowError):
I need a way to create (and use) an array of char pointers. Can you please take a look?
Thank you!