Changes between Version 13 and Version 14 of Ticket #13072


Ignore:
Timestamp:
08/29/12 12:27:43 (8 years ago)
Author:
andrew.mathas
Comment:

The following timings show that there is a dramatic speed-up when number_of_partitions is cached:

With caching:

sage: %timeit [Partitions(n).random_element() for n in range(100)]
25 loops, best of 3: 25 ms per loop
sage: %timeit [Partitions(n).random_element() for n in range(100)]
25 loops, best of 3: 24.6 ms per loop
sage: %timeit [Partitions(n).random_element() for n in range(100)]
25 loops, best of 3: 25.4 ms per loop

Without caching:

sage: %timeit [Partitions(n).random_element() for n in range(100)]
5 loops, best of 3: 1.23 s per loop
sage: %timeit [Partitions(n).random_element() for n in range(100)]
5 loops, best of 3: 1.23 s per loop
sage: %timeit [Partitions(n).random_element() for n in range(100)]
5 loops, best of 3: 1.26 s per loop

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #13072 – Description

    v13 v14  
    4242    1. A=sage.combinat.partition.number_of_partitions() is marked for deprecation in favour of B=sage.combinat.partitions.number_of_partitions(), which is what function A() calls most of the time. As agreed above, number_of_partitions() will stay in the global name space, but this made the deprecation somewhat fiddly as I did not want to deprecate number_of_partitions() for "normal use" because from the user perspective this function will not change. Instead, I have deprecated the individual options of number_of_partitions() so deprecation warnings are only generated when A() does NOT call B(). In the global namespace, number_of_partitions still points to A(). When the functions which are marked for deprecation below are removed, number_of_partitions() should be changed to point to B() and A() should be changed into a deprecated_function_alias to B(). See the patch for more details.
    4343
    44     2. For use in Partitions().random_element() the function number_of_partitions() was cached. This cached function was almost never used so, assuming that caching this function is a good idea, I decided to cache sage.combinat.partitions.number_of_partitions() always. Please let me know if this is a bad idea.
     44    2. For use in Partitions().random_element() the function number_of_partitions() was cached. This cached function was almost never used so, assuming that caching this function is a good idea, I decided to cache sage.combinat.partitions.number_of_partitions() always. Please let me know if this is a bad idea. ''In fact, this leads to a dramatic speed-up. See the timings below''.
    4545
    4646    3. The two functions