Ticket #425 (closed enhancement: fixed)

Opened 4 years ago

Last modified 4 years ago

Drop redundant ref-counting on parallel swap assignments

Reported by: scoder Owned by: scoder
Priority: major Milestone: 0.12
Component: Optimization Keywords:
Cc:

Description

The ref-counting for parallel swap assignments is redundant, i.e.

cdef object a = ..., b = ...
a,b = b,a

should be a simple pointer exchange through a temp variable. The same applies to swapping list or buffer items. The general rules are:

  • the sets of names/expressions on both sides must be identical
  • no value must appear more than once on either side, i.e. this must be prohibited: a,b,b = a,a,b
  • all values on both sides of an assignment must have Python object types
  • attribute access is only allowed at the C level, i.e. no Python attributes or properties
  • item access (indexing) is only allowed for C types, including buffers and Python lists

Change History

Changed 4 years ago by scoder

See also ticket #426.

Changed 4 years ago by scoder

  • owner changed from somebody to scoder

Changed 4 years ago by scoder

Simple local variable swapping is implemented here:

 http://hg.cython.org/cython-devel/rev/1f0d7bae2d4e

Detecting optimisable IndexNode assignments is implemented here:

 http://hg.cython.org/cython-devel/rev/43f5edccdf13

The optimisation itself is pending for index assignments, as this requires changes to __Pyx_GetItemInt() and friends.

Changed 4 years ago by scoder

  • status changed from new to closed
  • resolution set to fixed
  • milestone changed from wishlist to 0.12

Attribute access is optimised here:

 http://hg.cython.org/cython-devel/rev/93a98a1f016a

Follow-up for index access in #438.

Note: See TracTickets for help on using tickets.