emilydolson / phylotrackpy

Python phylogeny tracker for in silico evolution experiments
MIT License
10 stars 2 forks source link

Avoid storing __eq__ operator for every taxon_info object #60

Open emilydolson opened 10 months ago

emilydolson commented 10 months ago

Currently, to support NumPy's unconventional == operator (returns array of bools, not a bool), the constructor for taxon_info reaches into Python, grabs the object's classes __eq__ operator, and then uses a try-catch statement to swap in the numpy.array_equal operator.

For a given systematics manager, however, the == should be the same for all taxon_info objects. Thus, there is almost certainly a way to store single copy per systematics manager and avoid having to reach into Python every time the constructor is called.

Possible solutions:

  1. The equals operator could live in the wrapped systematics object (need to figure out how to give taxon_info objects access to it).
  2. The taxon_info object could have the equals operator as a static member (tricky, because it can seg-fault on destruction)