S
S
shansung2016-03-29 00:54:44
Python
shansung, 2016-03-29 00:54:44

How many cycles does one addition operation take in python?

How many cycles does one addition operation take in python on a single core processor?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Axian Ltd., 2016-03-29
@AxianLTD

Python interpreter. Accordingly, the first time the calculation is slower. The following times the bycode is already executed. However, different implementations (versions, builds) of Python, on different platforms, for different data types on the same physical machine will use a different number of machine cycles. The question is incorrect IMHO. It is more correct to ask, for example, how long does an integer addition operation take on average in Python 2.7 on a Windows 8 x86 platform.

T
thenno, 2016-03-29
@thenno

A strange question - at least what types are you going to add?
If you are interested in running time - profile through the tools built into python or the time utility. If for a task it is necessary to count cycles, then you need to look at C / ASM or another system language without garbage collection, but not at all at managed scripting languages, where it is unlikely that you can take and find out exactly how many cycles this or that operation will take, but stop the world for garbage collection will hang the entire application at the most inopportune moment.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question