t += ( content, )
 return t
 $$ LANGUAGE plpython3u;
+CREATE FUNCTION test_setof_as_set(count integer, content text) RETURNS SETOF text AS $$
+s = set()
+for i in range(count):
+   s.add(content * (i + 1) if content is not None else None)
+return s
+$$ LANGUAGE plpython3u;
 CREATE FUNCTION test_setof_as_iterator(count integer, content text) RETURNS SETOF text AS $$
 class producer:
    def __init__ (self, icount, icontent):
  
 (2 rows)
 
+SELECT * FROM test_setof_as_set(0, 'set') ORDER BY 1;
+ test_setof_as_set 
+-------------------
+(0 rows)
+
+SELECT * FROM test_setof_as_set(1, 'set') ORDER BY 1;
+ test_setof_as_set 
+-------------------
+ set
+(1 row)
+
+SELECT * FROM test_setof_as_set(2, 'set') ORDER BY 1;
+ test_setof_as_set 
+-------------------
+ set
+ setset
+(2 rows)
+
+SELECT * FROM test_setof_as_set(2, null) ORDER BY 1;
+ test_setof_as_set 
+-------------------
+ 
+(1 row)
+
 SELECT test_setof_as_iterator(0, 'list');
  test_setof_as_iterator 
 ------------------------
 
 return t
 $$ LANGUAGE plpython3u;
 
+CREATE FUNCTION test_setof_as_set(count integer, content text) RETURNS SETOF text AS $$
+s = set()
+for i in range(count):
+   s.add(content * (i + 1) if content is not None else None)
+return s
+$$ LANGUAGE plpython3u;
+
 CREATE FUNCTION test_setof_as_iterator(count integer, content text) RETURNS SETOF text AS $$
 class producer:
    def __init__ (self, icount, icontent):
 SELECT test_setof_as_tuple(2, 'tuple');
 SELECT test_setof_as_tuple(2, null);
 
+SELECT * FROM test_setof_as_set(0, 'set') ORDER BY 1;
+SELECT * FROM test_setof_as_set(1, 'set') ORDER BY 1;
+SELECT * FROM test_setof_as_set(2, 'set') ORDER BY 1;
+SELECT * FROM test_setof_as_set(2, null) ORDER BY 1;
+
 SELECT test_setof_as_iterator(0, 'list');
 SELECT test_setof_as_iterator(1, 'list');
 SELECT test_setof_as_iterator(2, 'list');