From: Hans Hagen <j.hagen@xs4all.nl>
To: Alan Braslau <braslau.list@comcast.net>,
Fabrice L <fabrice.alpha@gmail.com>,
mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Variable instance identifiers exhausted
Date: Wed, 19 Sep 2018 23:23:10 +0200 [thread overview]
Message-ID: <0691a61b-2de6-e998-db0a-01fc5381f241@xs4all.nl> (raw)
In-Reply-To: <20180919144547.2bf4c77f@comcast.net>
On 9/19/2018 10:45 PM, Alan Braslau wrote:
> Metapost does not have a very efficient mechanism for keeping objects in memory and does not have a very efficient or real array mechanism, rather it uses hashed lists.
fwiw, keeping objects as such in memory is quite ok, hashing is also ok,
but indeed arrays are not really arrays but linked lists into the hash
(which actually you can speed up a lot)
so, here is a teaser for Alan (no lua magic here, just knowledge of how
mp hashes):
\dontleavehmode \testfeatureonce{1}{
\startMPcode
numeric foo[];
def set_foo(expr c, s) =
foo[c]:= s ;
enddef ;
def get_foo(expr c) =
foo[c]
enddef ;
for i=1 upto 10000 :
set_foo(i,i) ;
endfor ;
draw textext("set one dimensional");
\stopMPcode
} \elapsedtime \blank
\dontleavehmode \testfeatureonce{1}{
\startMPcode
numeric n ;
for i=1 upto 10000 :
n := get_foo(i) ;
endfor ;
draw textext("get one dimensional");
\stopMPcode
} \elapsedtime \blank
\dontleavehmode \testfeatureonce{1}{
\startMPcode
numeric foo[][][][];
def set_foo(expr c, s) =
foo[c div 1000][c div 100][c div 10][c] := s ;
enddef ;
def get_foo(expr c) =
foo[c div 1000][c div 100][c div 10][c]
enddef ;
for i=1 upto 10000 :
set_foo(i,i) ;
endfor ;
numeric n ;
for i=1 upto 10000 :
n := get_foo(i) ;
endfor ;
draw textext("set four dimensional" );
\stopMPcode
} \elapsedtime \blank
\dontleavehmode \testfeatureonce{1}{
\startMPcode
numeric n ;
for i=1 upto 10000 :
n := get_foo(i) ;
endfor ;
draw textext("get four dimensional");
\stopMPcode
} \elapsedtime \blank
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2018-09-19 21:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-17 19:17 Fabrice L
2018-09-18 5:15 ` luigi scarso
2018-09-19 2:21 ` Fabrice L
2018-09-19 19:28 ` Alan Braslau
[not found] ` <CANy7HnaTRj4jc0yyMGDoH5fumSQAdhEpB=zfYPRK=bVFJgox0A@mail.gmail.com>
[not found] ` <20180919144547.2bf4c77f@comcast.net>
2018-09-19 21:23 ` Hans Hagen [this message]
2018-09-21 15:04 ` Fabrice L
2018-09-21 17:28 ` Hans Hagen
2018-09-18 7:11 ` Taco Hoekwater
2018-09-19 2:24 ` Fabrice L
2018-09-19 7:28 ` Hans Hagen
2018-09-19 19:24 ` Alan Braslau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0691a61b-2de6-e998-db0a-01fc5381f241@xs4all.nl \
--to=j.hagen@xs4all.nl \
--cc=braslau.list@comcast.net \
--cc=fabrice.alpha@gmail.com \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).