[New-bugs-announce] [issue24242] property performance regression
Hannes Ovrén
report at bugs.python.org
Tue May 19 16:24:08 CEST 2015
New submission from Hannes Ovrén:
There seems to be a significant regression in performance when using @property in Python 2.x compared to 3.x.
Test code:
class A:
def __init__(self, x, y):
self.x = x
self.y = y
@property
def y(self):
return self._y
@y.setter
def y(self, value):
self._y = value
from timeit import timeit
a = A(1, 2)
timeit('a.x', 'from __main__ import a')
timeit('a.y', 'from __main__ import a')
On my machine (Fedora Linux, x64) I get the following timings:
2.7.8:
a.x : 0.05482792854309082
a.y : 0.05585598945617676
3.4.1:
a.x : 0.06391137995524332
a.y : 0.31193224899470806
I.e. The performace of using a property vs a ordinary member is more or less the same in 2.7, while it incurs a 5x penalty in 3.4.
----------
messages: 243595
nosy: hovren
priority: normal
severity: normal
status: open
title: property performance regression
type: performance
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24242>
_______________________________________
More information about the New-bugs-announce
mailing list