On Oct 8, 2015, at 2:38 PM, John M wrote:
> This seems odd... surely you can't go faster that iterating over the atoms
> and counting element 6?
One is in C++, the other is in Python.
> Perhaps the python iter is indeed slower than a SMARTS match but that can't
> be true?
The "for atom in mol.GetAtoms()" iterator, which makes a Python proxy for the
C++ object, takes 75% of the run-time.
That is, if I precompute:
atoms = list(mol.GetAtoms())
then do 1000 iterations of
return sum(1 for atom in atoms if atom.GetAtomicNum() == 6)
instead of
return sum(1 for atom in mol.GetAtoms() if atom.GetAtomicNum() == 6)
then the overall time for a benchmark dropped from 76 to 18 seconds.
Andrew
[email protected]
------------------------------------------------------------------------------
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss