Skip to content

Commit b5550fd

Browse files
committed
Cythonize Molecule.get_element_count()
Probably won't speed it up much, but we might as well.
1 parent e85242a commit b5550fd

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

rmgpy/molecule/molecule.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,15 +1590,14 @@ def get_element_count(self):
15901590
"""
15911591
Returns the element count for the molecule as a dictionary.
15921592
"""
1593+
cython.declare(atom=Atom, element_count=dict, symbol=str, key=str)
15931594
element_count = {}
15941595
for atom in self.atoms:
15951596
symbol = atom.element.symbol
1596-
isotope = atom.element.isotope
1597-
key = symbol
1598-
if key in element_count:
1599-
element_count[key] += 1
1597+
if symbol in element_count:
1598+
element_count[symbol] += 1
16001599
else:
1601-
element_count[key] = 1
1600+
element_count[symbol] = 1
16021601

16031602
return element_count
16041603

0 commit comments

Comments
 (0)