1. object replication

Below is a routine to copy any object "exactly". But my intent is really to
release the original object from any pointers. This will have speed
benefits. However I am not sure that a full image will be created and not be
simply a bunch of pointers. Can anyone help? Rob?

function seq(object x)
sequence result
if atom(x) then return x end if
if length(x) then
  result=repeat(0,length(x))
  for i= 1 to length(x) do
   result[i]=seq(x[i])
  end for
else return{}
end if
return result
end function

sequence any
}}

sequence other
other = seq(any)

? any
? other -- identical to 'any'

Yours truly
Michael Palffy
michael at igrin.co.nz

new topic     » topic index » view message » categorize

2. Re: object replication

Michael Palffy writes:
> Below is a routine to copy any object "exactly". But my
> intent is really to release the original object from any pointers.
> This will have speed benefits.

Can you create an example that shows these alleged speed benefits?
I really don't see the point to this.

> However I am not sure that
> a full image will be created and not be simply a bunch of pointers.
> Can anyone help? Rob?

As it turns out, your routine will not make a unique copy of
floating-point atoms, only sequences. Again,
I don't see any advantage to using your routine.
When it's necessary, Euphoria will make a copy much faster
than you can using your routine.

Regards,
     Rob Craig
     Rapid Deployment Software
     http://members.aol.com/FilesEu/

new topic     » goto parent     » topic index » view message » categorize

3. Re: object replication

In A message I wrote were the following statements:


>> Below is a routine to copy any object "exactly". But my
>> intent is really to release the original object from any pointers.
>> This will have speed benefits.


Rob replied:

>Can you create an example that shows these alleged speed benefits?
>I really don't see the point to this.


Actually I thought that I did have an example of speed degradation in
sequences. You see, a few months ago I wrote a small program to provide some
useful data for the office that I work at. Basically, the program read in
two lists of  data and then amalgamated them using a common attribute, ie
the clients ID number. The original lists contained about 4000 entries and
after amalgamation 1500. Now, when I first ran this program I observed the
counter on the screen. Initially the counter was updating very quickly but
it soon slowed down and continued doing so until all records have been
processed. I PRESUMED that this was due to the pointer-istic (if such a term
be allowed) nature of the sequence in Euphoria. Well, I have spent a couple
hours recreating this program and, you know, I cannot duplicate the anomaly.
Whats more, the entire program now takes only 3 seconds to run. This is
somewhat different from the minute or so that it required previously.

[quickly changing topic]

Could someone please send me a copy of the program i posted called
minute.exw . All mine got vapourised a few weeks ago by you-know-who.

Yours truly
Michael Palffy

michael at igrin.co.nz

new topic     » goto parent     » topic index » view message » categorize

4. Re: object replication

>>> Below is a routine to copy any object "exactly". But my
>>> intent is really to release the original object from any pointers.
>>> This will have speed benefits.


It didnt do that.
This trick would:

function duplicate (object x)

  -- Depending on how smart ex.exe is:
    x = x + 0
  -- If it is too smart:
    x = x + 1
    x = x - 1

    return x
end function

>Rob replied:
>
>>Can you create an example that shows these alleged speed benefits?
>>I really don't see the point to this.
>
>Actually I thought that I did have an example of speed degradation in
>sequences. You see, a few months ago I wrote a small program to provide
some
>useful data for the office that I work at. Basically, the program read in
>two lists of  data and then amalgamated them using a common attribute, ie
>the clients ID number. The original lists contained about 4000 entries and
>after amalgamation 1500. Now, when I first ran this program I observed the
>counter on the screen. Initially the counter was updating very quickly but
>it soon slowed down and continued doing so until all records have been
>processed. I PRESUMED that this was due to the pointer-istic (if such a
term
>be allowed) nature of the sequence in Euphoria. Well, I have spent a couple
>hours recreating this program and, you know, I cannot duplicate the
anomaly.
>Whats more, the entire program now takes only 3 seconds to run. This is
>somewhat different from the minute or so that it required previously.



There are two possible explenations for this, that I can come up with:
* The file and program were now still in the cache: this speed things up
alot.
    Were you using append () or & ??

* You forced ex.exe to work with two different sequence, in such way, it has
to reproduce every sequence every time, these things are esspecially nasty
in recursion. Try not to use an sequence after you copied it to another
sequence.

As it sounds I think the speed benefit was, that ex.exe figured it did NOT
have to copy the sequence at all. Since the old sequence wasnt used anymore.
You can try the above. Add the routine to your program and use it. It will
enormously slow down your program. That is my guess.

PS. There *are* reasons to be found for such a routine to exist though.
Whenever the object duplication is going to happen, and you want it to
happen at some other time. Before the game starts, when it is still
displaying the 'loading' text on the screen. I would like it if Euphoria
optimized around statement blocks like it already does a bit with the
for-loop.

Ralf

new topic     » goto parent     » topic index » view message » categorize

5. Re: object replication

errr... someone wrote:
>>Well, I have spent a couple hours recreating this program
>>and, you know, I cannot duplicate the anomaly.

Ralf Nieuwenhuijsen wrote:
>There are two possible explenations for this, that I can come up with:

i've thought of another possible explanation...

what version of EU were you using before and what version are
you using now???

if you're using a later version, it could handily explain
the anomaly that can't be reproduced...

--Hawke'

new topic     » goto parent     » topic index » view message » categorize

6. Re: object replication

I think the reason for the first routine performing so badly was inefficient
programming technique. I had been appending the entire resultant sequence
together, say, 1500 * 12 appendations(including piecing of name strings
together) . But my second routine declared space first (in a manner of
speaking), ie:

sequence result
result=repeat({0,0,0,0,0,0,0,0,0,0,0,0},1500)

and then various direct assignments were made to it.


>errr... someone wrote:
>>>Well, I have spent a couple hours recreating this program
>>>and, you know, I cannot duplicate the anomaly.
>
>Ralf Nieuwenhuijsen wrote:
>>There are two possible explenations for this, that I can come up with:
>
>i've thought of another possible explanation...
>
>what version of EU were you using before and what version are
>you using now???
>
>if you're using a later version, it could handily explain
>the anomaly that can't be reproduced...
>

new topic     » goto parent     » topic index » view message » categorize

7. Re: object replication

Michael,

It is perfectly good Euphoria, and better readable, to write:
result =3D repeat(repeat(0, 12), 1500))

>I think the reason for the first routine performing so badly was
inefficient
>programming technique. I had been appending the entire resultant sequenc=
e
>together, say, 1500 * 12 appendations(including piecing of name strings
>together) . But my second routine declared space first (in a manner of
>speaking), ie:

>sequence result
>result=3Drepeat({0,0,0,0,0,0,0,0,0,0,0,0},1500)

>and then various direct assignments were made to it.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu