[issue33267] ctypes array types create reference cycles

2018-04-12 Thread Josh Rosenberg

Josh Rosenberg  added the comment:

Pretty sure this is a problem with classes in general; classes are 
self-referencing, and using multiplication to create new ctypes array types is 
creating new classes.

--
nosy: +josh.r

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33267] ctypes array types create reference cycles

2018-04-12 Thread Ned Deily

Change by Ned Deily :


--
nosy: +amaury.forgeotdarc, belopolsky, meador.inge

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33267] ctypes array types create reference cycles

2018-04-12 Thread Eric Wieser

Eric Wieser  added the comment:

Apologies, I missed the important part of that snippet:
```
In [3]: gc.collect(); x = make_array_ctype((1,)); del x; gc.collect()
Out[3]: 7
```

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33267] ctypes array types create reference cycles

2018-04-12 Thread Eric Wieser

New submission from Eric Wieser :

Discovered in https://github.com/numpy/numpy/pull/10882/files#r180813166

A reproduction:
```
In [1]: import ctypes

In [2]: def make_array_ctype(shape):
   ...: import ctypes
   ...: ct = ctypes.c_uint8
   ...: for i in shape:
   ...: ct = i * ct
   ...: return ct
   ...:

# all on one line to keep ipython out of this
In [3]: gc.collect(); x = make_array_ctype((1,)); del x; gc.collect()
```

Using the proposed function in https://github.com/numpy/numpy/pull/10891, we 
get a few more details:
```
In [4]: from numpy.testing import assert_no_gc_cycles

In [5]: assert_no_gc_cycles(make_array_ctype, (1,))
AssertionError: Reference cycles were found when calling make_array_ctype: 7 
objects were collected, of which 6 are shown below:
  tuple object with id=282226536:
(,)
  PyCArrayType object with id=286500408:

  getset_descriptor object with id=2822252062256:

  getset_descriptor object with id=2822252062184:

  tuple object with id=2822243712440:
(,
 ,
 ,
 )
  StgDict object with id=286211928:
{'__dict__': ,
 '__doc__': None,
 '__module__': '__main__',
 '__weakref__': ,
 '_length_': 1,
 '_type_': }
```

I suppose this isn't really a bug, but it's not clear to me why a cycle needs 
to be created here.

--
components: ctypes
messages: 315216
nosy: Eric.Wieser
priority: normal
severity: normal
status: open
title: ctypes array types create reference cycles
versions: Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com