Using python memory in nupic.core



During our last community meetup I raised the point that the current implementation of nupic.core does cache and use memory areas (via pointers) created in python. This is mostly from memory allocated by numpy arrays.

One example of this pattern is when Cells4::setStatePointers(…) is called. Supsequent calls to Cells4::computer(…) will then fill in values into these arrays.

There is nothing wrong with such practice but it might just make it more difficult for other language bindings providers similar functionality.


Well, actually I have spent some time working on the nupic::Array class which is the one that holds the buffer allocated in Python. I think I have a way of implementing that in C# such that it originates as an array in C# and is passed into the core. The objective is to avoid making a copy of the array at the language interface.

Most languages have a Byte (or char) or a Single (or float) as a basic type and that is what underpins the arrays.

So I think we are good.


There have been some new data types added recently in C# that might be useful?



That looks very interesting. I will try to work that into the interface someplace.


You also have the option of just copying the data and have the client pick it up later. It might be slower but less risky in regards to a client messing up.