#6927: [with patch, needs work] extend CachedFunction to handle disk-cache
-------------------------+--------------------------------------------------
 Reporter:  boothby      |       Owner:  boothby       
     Type:  enhancement  |      Status:  new           
 Priority:  major        |   Milestone:  sage-feature  
Component:  misc         |    Keywords:  cache database
 Reviewer:  Tim Dumol    |      Author:  boothby       
   Merged:               |  
-------------------------+--------------------------------------------------
Changes (by timdumol):

  * reviewer:  => Tim Dumol


Comment:

 I'm not sure if this problem is local to this patch, but running:

 {{{
 @cached_function
 def oddprime_factors(n):
      l = [p for p,e in factor(n) if p != 2]
      return len(l)
 oddprime_factors.precompute(range(1,100), 4)
 }}}

 , which is in the doctets of `cachefunc.py`, in the Notebook throws a
 `NameError`:

 {{{
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/home/deadlyx/.sage/sage_notebook/worksheets/admin/0/code/1.py",
 line 13, in <module>
     oddprime_factors.precompute(range(_sage_const_1 ,_sage_const_100 ),
 _sage_const_4 )
   File "", line 1, in <module>

   File "/opt/sage-bin/local/lib/python2.6/site-
 packages/sage/misc/cachefunc.py", line 226, in precompute
     for ((args,kwargs), val) in P(arglist):
   File "/opt/sage-bin/local/lib/python2.6/site-
 packages/sage/parallel/multiprocessing.py", line 66, in parallel_iter
     for res in result:
   File "/opt/sage-bin/local/lib/python2.6/site-
 packages/processing/pool.py", line 470, in next
     raise value
 NameError: global name '_sage_const_2' is not defined
 }}}

 Running it in the command line works perfectly.

  * The paths for `FileCache` are not OS agnostic: Windows uses
 backslashes, instead of slashes. Using `os.sep` instead should fix it.
  * The examples in the docstrings are not properly formatted. To display
 them as a code block, please use the ff. format:

 {{{

 EXAMPLES::

     sage: foo()
     bar
     sage: bar()
     baz

 :: # Another code block

     sage: foo()
     foo

 }}}

 Everything else seems to work well. Oh, it may be worth hashing the
 function being cached and adding that to the key. It should prevent
 problems with using the same directory for the cache folder.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/6927#comment:6>
Sage <http://sagemath.org/>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to