# Swig and raw pointers

**URL:** <https://discourse.numenta.org/t/swig-and-raw-pointers/3191>\
**Category:** NuPIC\
**Created:** [December 21, 2017, 6:01pm UTC](https://discourse.numenta.org/t/swig-and-raw-pointers/3191 "2017-12-21T18:01:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chhenning](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/chhenning/32/3821_2.png) [@chhenning](https://discourse.numenta.org/u/chhenning)\
**Post date:** [December 21, 2017, 6:01pm UTC](https://discourse.numenta.org/t/swig-and-raw-pointers/3191/1 "2017-12-21T18:01:21Z")

</div>

Hi all, I have a question how swig handles interfaces that return a raw pointer. For instance, when creating a network in python

```auto
network = engine.Network()
network.addRegion("region1", "TestNode", "")
network.addRegion("region2", "TestNode", "")

region1 = network.getRegions().getByName("region1")

```

The piece “network.getRegions()” returns a Collection\<Region\*\> in cpp. I assume that the pointers are convert to a nupic’s pyObject. Is that correct? If so, where is this logic implemented?

I’m inclined to switch to std::shared\_pointer instead of raw pointers. At least this is supported by pybind11. Are there any good reasons not to do this?

Thanks,  
Christian
