Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Function creation slows code >10X

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63397] Function creation slows code >10X
  • From: pdickof at scf.sk.ca
  • Date: Thu, 29 Dec 2005 02:57:28 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

directResult =
      Union[Map[Apply[
      tagTree[[##]][[1]] &, #] &, Position[
              tagTree, _?(leafRuleQ[#] &)]]]; // AbsoluteTiming

takes 1.3 seconds

newLeafTags[tagTree_] :=
    Union[Map[Apply[tagTree[[##]][[1]] &, #] &, Position[tagTree, \
_?(leafRuleQ[#] &)]]];
funcResult = newLeafTags[tagTree]; // AbsoluteTiming

takes 20 seconds. even though
funcResult===directResult
returns True

In another case, 8 lines which take 12 seconds as separate lines take
>500 seconds
when a function is declared with a module statement wrapped around them
even though no local variables are declared in the module.

Why is this happening and how can I avoid it???

I don't see why it should matter, but
- tagTree is a large, complicated nested rule like (eg.)
a->{b->c,d->{e->f},g->h}.
- leafRuleQ returns True for g->h and False for d->{e->f}, and
- newLeafTags returns {b,e,g} for the example


  • Prev by Date: Mathematica code & Latex
  • Next by Date: Re: Piecewise Integration Woes
  • Previous by thread: Re: Mathematica code & Latex
  • Next by thread: Re: Piecewise Integration Woes