[issue36012] Investigate slow writes to class variables

2019-02-20 Thread Raymond Hettinger
Change by Raymond Hettinger : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue36012] Investigate slow writes to class variables

2019-02-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset d8b9e1fc2e45d2bc3f4a9737c375f2adb8a8c7de by Raymond Hettinger (Stefan Behnel) in branch 'master': bpo-36012: Avoid linear slot search for non-dunder methods (GH-11907)

[issue36012] Investigate slow writes to class variables

2019-02-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: Thanks Neil. The tooling does indeed look nice. I added your PyUnicode_InternInPlace() suggestion to the PR. At this point, the PR looks ready-to-go unless any of you think we've missed some low-hanging fruit. --

[issue36012] Investigate slow writes to class variables

2019-02-19 Thread Neil Schemenauer
Neil Schemenauer added the comment: BTW, 'perf report [...]' has a really neat annotated assembly view. Scroll to the function you are interested in and press 'a'. Press 't' to toggle the time units (left side numbers). I'm attaching a screenshot of the disassembly of the lookdict

[issue36012] Investigate slow writes to class variables

2019-02-19 Thread Neil Schemenauer
Neil Schemenauer added the comment: Some profiling using 'perf'. This is for cpython 63fa1cfece4912110ce3a0ff11fb3ade3ff5e756. children self [...] + 97.27% 0.00% run_mod (inlined) + 88.53% 6.33% PyObject_SetAttr + 79.34% 6.80% type_setattro + 43.92%43.92%

[issue36012] Investigate slow writes to class variables

2019-02-19 Thread STINNER Victor
Change by STINNER Victor : -- nosy: -vstinner ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue36012] Investigate slow writes to class variables

2019-02-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: Wow, I didn't expect to get an immediate win this of this magnitude :-) -- ___ Python tracker ___

[issue36012] Investigate slow writes to class variables

2019-02-17 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: This are the timings that I am measuring with PR 11907: Variable and attribute read access: 5.7 ns read_local 5.9 ns read_nonlocal 16.2 ns read_global 24.5 ns read_builtin 20.9 ns read_classvar_from_class

[issue36012] Investigate slow writes to class variables

2019-02-17 Thread Stefan Behnel
Stefan Behnel added the comment: It turns out that "update_slot()" is always called, even when we are not updating a slot name (which is always a special dunder-name). The linear search for names in "update_slots()" is a huge waste of time here, and short-circuiting out of it when the name

[issue36012] Investigate slow writes to class variables

2019-02-17 Thread Stefan Behnel
Change by Stefan Behnel : -- keywords: +patch pull_requests: +11932 stage: -> patch review ___ Python tracker ___ ___

[issue36012] Investigate slow writes to class variables

2019-02-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: > can you include your python 2.7 runs? for me it looks similar It will give similar results unless you switch to old-style classes (edit out the inheritance from object). class A: pass A.x = 1 --- $

[issue36012] Investigate slow writes to class variables

2019-02-16 Thread Yasser Alshalaan
Yasser Alshalaan added the comment: can you include your python 2.7 runs? for me it looks similar -- nosy: +Yasser Alshalaan ___ Python tracker ___

[issue36012] Investigate slow writes to class variables

2019-02-16 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: It seems 50% of the overhead (50ns) is due to two reasons: - 30-40% is due to the call to update_slot(type, name) after the item is set in the class dictionary. - 70-60% is due to all the extra work from _PyObject_GenericSetAttrWithDict until it

[issue36012] Investigate slow writes to class variables

2019-02-16 Thread Raymond Hettinger
New submission from Raymond Hettinger : Benchmark show what writes to class variables are anomalously slow. class A(object): pass A.x = 1 # This write is 3 to 5 times slower than other writes. FWIW, the same operation for old-style classes in Python 2.7 was several times