In addition to the standard Python types, types defined by the user (using the class statement) can also be made shareable. These types have to be registered with POSH using the posh.allow_sharing function, which will create an appropriate shared type through sub-typing. User-defined shareable types have to be registered prior to any posh.fork() calls, in order for the shared types to remain accessible to all processes.
For instance, Figure 4 shows the definition of a new Parrot type whose instances will be shareable. There is nothing special about the type definition in itself -- the only point of interest is the call to allow_sharing following the class statement. The arguments to allow_sharing are the shareable type and an optional initializer function. The latter is a function that specifies how to create a new instance of the shared type given an instance of the shareable type. In this particular example, the function specifies how to create a shared Parrot object from an existing non-shared Parrot object. The function used in the example, posh.generic_init, will be appropriate for many user-defined types. It assigns all the attributes of the non-shared object to a new shared object. The user may freely define new initializer functions as needed.
An interpreter session that illustrates the use of a shared Parrot object is listed in Figure 5. The final line reveals that the object, while behaving exactly like a Parrot object, is in fact a proxy object for a shared object. The attributes that are assigned to shared objects are implicitly shared, just like the items assigned to shared lists and dictionaries.