r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!REBOL3-OLD1]

BrianH
9-Feb-2009
[10840]
We are extending support of many of the functions that people traditionally 
associated with series to objects and maps, without making them into 
series. So that means that APPEND works, but INSERT doesn't because 
of the position stuff.
Pavel
9-Feb-2009
[10841]
For Map also limit about 500000 items was mentioned, it suggest an 
idea use Map in pagged manner. Ie for larger set use multiple Maps 
rather fixed size in the manner of cache.
Dockimbel
9-Feb-2009
[10842]
Pavel: is map! any better in that case?
Pavel
9-Feb-2009
[10843]
I have no exact comparison all mentioned is only ideas
BrianH
9-Feb-2009
[10844]
SELECT works on object! and map! but FIND doesn't. PICK and POKE 
work, but they take keys rather than indexes. There are some (at 
this point undocumented) limits on what can be used as keys too (at 
least you can't use a block as a key in practice), but that may be 
a bug.
Dockimbel
9-Feb-2009
[10845]
Lot of new exceptions to remember...
Pavel
9-Feb-2009
[10846]
Brian Block as key would be good for reversed index IMO. Question 
if it would be usefull.
BrianH
9-Feb-2009
[10847]
Well, in some cases to fix, but yes, lots of exceptions. The guideline 
is that maps and objects don't have position, but series do. So the 
position-dependent functions don't work but their non-position-dependent 
counterparts do. Ports don't work like series either, so there is 
another whole set of differences to remember.
Dockimbel
9-Feb-2009
[10848]
Good point Pavel, how does map! handle the key/key case? (being able 
to exchange the role of key<=>value). Would it require to use two 
map! to being able to do fast lookups in both cases? So n-tuple stored 
=> n map! value to hash everything?
BrianH
9-Feb-2009
[10849x2]
Pavel, the problem is that we can't hash complex structures (for 
now) so there is no advantage to using them as keys. I want a keys-of 
function though that returns a block of the keys that reference a 
value (by same? semantics for the value, perhaps).
The words-of function already returns *all* of the keys of a map!, 
just like it does for objects.
Pavel
9-Feb-2009
[10851]
I dont want to use keys in this way (difficult keys) the opposite 
is true, keys should be simplest possible.
BrianH
9-Feb-2009
[10852]
Well then you have no problem then :)
Pavel
9-Feb-2009
[10853x3]
Doc I think so
But it is not necessary week point if the design of data would be 
good
Anyway it leads to multiple lookup when data is difficult
BrianH
9-Feb-2009
[10856x2]
I agree, Doc, that sounds like a good plan. Map! storage and implementation 
is in theory more efficient than hash!, so having two of them shouldn't 
be a problem, as long as your wrapper functions keep track of the 
mirroring.
The only trick is that you remember that none means nothing, so don't 
bother with a none key. The theory of map! is either:

- Keys that are associated with none don't exist in the map!, so 
assigning none to a key makes it go away.

- All possible keys are in the map! but only the ones associated 
with something other than none are displayed.

There is no difference between these two theories in practice, and 
whether there is memory allocated for keys that you can't see is 
an implementation detail that is irrelevant to the use of map! (though 
there is usually not).
Steeve
9-Feb-2009
[10858]
something related, in the past i made some tests to simulate hashs 
with integer keys in R2. I used a bitset as an index, mixed with 
block of blocks to store data.

my tests show that for 10000 records,  finding data is near as fast 
as with hashs. 
actually it's incomplete but you have the idea with this:

REBOL []
f: fast-dic: context [
	size: 100000

 hash: 128 - 1	;** hash size speed up the search, must be a power 
 of 2 - 1 (ie. 15, 31, 63, 127, 257 ...)
	master: copy/deep head insert/dup/only [] [] hash + 1
	index: make bitset! size
	flag: func [idx [integer!]][
		unless find index idx [
			insert index idx

   insert/only insert tail pick master idx and hash + 1 idx copy []
		]
	]
	flag?: func [idx [integer!]][find index idx]
	deflag: func [idx [integer!]][
		remove/part index idx
		remove/part find pick master idx and hash + 1 idx 2
	]
] 

t: now/time/precise
loop 10000 bind [flag random 99999] f
print now/time/precise - t
t: now/time/precise
loop 10000 bind [flag? random 99999] f
print now/time/precise - t
GiuseppeC
9-Feb-2009
[10859]
Just a question. Is there a way to rappresent  Unicode Characters 
inside a string with an escape sequence ?
BrianH
9-Feb-2009
[10860x2]
^(hex characters)

. The console may not render the character properly if the font doesn't 
support it though - it may look like a space.
Same as R2, but you can provide more hex characters.
[unknown: 5]
9-Feb-2009
[10862]
Yes Pavel, that is the way it looks to me also regarding the vector.
BrianH
9-Feb-2009
[10863]
Yeah, vector! doesn't work yet. There are a lot of tickets for vector!, 
all deferred. That to-block bug is not there, but not unexpected.
[unknown: 5]
9-Feb-2009
[10864x2]
Brian, I think we need to address the lack of list in R3.  Maybe 
a list like handling of block data that still returns a block.
at the performance level of list.
BrianH
9-Feb-2009
[10866x4]
I think that would be an excellent thing to address with a user-defined 
datatype.
People in general didn't use list!, because of the bugs and because 
block! was good enough for most uses. We haven't felt its lack for 
a year now. Most of the advantage of list! in regular code was handled 
by allowing insert and remove at the head of a block! to expand or 
contract the block, just like it does at the end, without a block 
copy. Just by making block! more efficient for inserts and removes, 
we have made list! even less necessary.
For that matter, you can make blocks even faster by getting rid of 
list!, just by enabling more optimizations.
The real advantage of list! wasn't the speed though, it was the alias 
persistancy. That was the source of the bugs in list! too.
Rebolek
9-Feb-2009
[10870]
I tested vector! extensively about one and half year ago. Not much 
changed, I think. The BIGGEST problem with vector! is that it's zero 
based.
BrianH
9-Feb-2009
[10871]
Trust me, vector! has bigger problems than that right now. I expect 
that it will not end up 0-based though, even with all of the advantages 
that 0-based vectors give us. It is likely that we will instead have 
0-based versions of PICK and POKE that work on all series.
Rebolek
9-Feb-2009
[10872]
Brian, all the vector! tickets are mine, so I know very well about 
vector! problems :) I'm not sure about zero based PICK and POKE, 
I would probably prefer PICKZ and POKEZ, but I can get used to it.
BrianH
9-Feb-2009
[10873]
Yes, those would be good names for the aformentioned 0-based versions 
of PICK and POKE. PICK0 and POKE0 have also been suggested as names, 
though I prefer *Z. They could be natives (or mezzanines?) that call 
PICK and POKE internally. I think the only reason we don't have them 
already is that PICK is an action!, and the naming disagreement.
Kaj
9-Feb-2009
[10874]
Are blocks stored in memory as linked fragments?
Steeve
9-Feb-2009
[10875]
no
Kaj
9-Feb-2009
[10876]
How can inserts at the head and tail be done without moving the block, 
then?
Steeve
9-Feb-2009
[10877]
you asked for blocks not for lists
Kaj
9-Feb-2009
[10878]
Yes, Brian talks about blocks above
Steeve
9-Feb-2009
[10879]
where ?, i don't think so
Kaj
9-Feb-2009
[10880]
Iīm not talking about links for each item, but for fragments determined 
during use
Steeve
9-Feb-2009
[10881]
uh ? he just said that the performance have been improved with block 
operations, so that lists are no more requested. He didn't say that 
blocks are working like lists now
Kaj
9-Feb-2009
[10882]
I didnīt say that, either. But there must be something going on if 
you can insert without moving the memory
Steeve
9-Feb-2009
[10883]
where did he said that ?
Kaj
9-Feb-2009
[10884]
One screen up
Steeve
9-Feb-2009
[10885]
this ? "Just by making block! more efficient for inserts and removes, 
we have made list! even less necessary."
Kaj
9-Feb-2009
[10886]
The only way I can think of to keep the memory contiguous is advanced 
use of the hardware MMU, which would lead to partially used memory 
pages at the start and end of each block
Steeve
9-Feb-2009
[10887]
>> a: []
== []

>> dp [append a 1]
== make object! [
    timer: 32
    evals: 11
    eval-natives: 4
    eval-functions: 1
    series-made: 2
    series-freed: 1
    series-expanded: 1
    series-bytes: 464
    series-recycled: 0
    made-blocks: 1
    made-objects: 0
    recycles: 0
]


as you can see the block has been expanded, which means copied in 
another place
Kaj
9-Feb-2009
[10888]
That would contradict Brianīs statement even about R2
Steeve
9-Feb-2009
[10889]
Don't see when he stated that, anyway we just have to wait his return