Skip to content

Conversation

adjs
Copy link

@adjs adjs commented Dec 9, 2017

Unnecessary calls to sympy.N may increase computational cost

Description

Replace N(k) for k, where k = 1, 2, or 3

Motivation and Context

Improve performance. For instance
import sympy as sp

tic = time.time()
for k in range(1000):
a = 2
toc = time.time()
print('time without sympy.N', toc-tic, 's')

tic = time.time()
for k in range(1000):
a = sp.N(2)
toc = time.time()
print('time with sympy.N', toc-tic, 's')

outputs
time without sympy.N 5.888938903808594e-05 s
time with sympy.N 0.012852907180786133 s

How Has This Been Tested?

make test

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@adjs adjs mentioned this pull request Dec 9, 2017
9 tasks
@awcross1
Copy link
Owner

awcross1 commented Dec 9, 2017

Thank you @adjs for the improvement!

@awcross1 awcross1 merged this pull request into awcross1:mapper-issue-159 Dec 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants